Skip to content

Commit

Permalink
Feat: 新增自动翻译功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Dec 3, 2024
1 parent 6bf6826 commit a92a1c1
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 8 deletions.
2 changes: 2 additions & 0 deletions config/_default/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

[[imports]]
path = "github.com/hugo-fixit/FixIt"
[[imports]]
path = "github.com/hugo-fixit/cmpt-translate"
[[imports]]
path = "github.com/hugo-fixit/component-projects"
[[imports]]
Expand Down
33 changes: 31 additions & 2 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,12 @@ disableThemeInject = false
"inject/component-projects.html",
"inject/shortcode-rewards.html",
]
menuDesktop = []
menuMobile = []
menuDesktop = [
'inject/translate-menu-desktop.html',
]
menuMobile = [
'inject/translate-menu-mobile.html',
]
profile = [
"custom/profile.html",
]
Expand All @@ -768,6 +772,7 @@ disableThemeInject = false
widgets = []
assets = [
"custom/use-assets.html",
"inject/cmpt-translate.html",
"inject/shortcode-caniuse.html",
]
postFooterBefore = []
Expand Down Expand Up @@ -1245,6 +1250,30 @@ disableThemeInject = false
[projectsAdapters.params]
hiddenFromHomePage = true

# Auto translation configuration
# See: https://github.com/xnx3/translate/
[autoTranslate]
enable = true
# The translation service provider, ['client.edge', 'translate.service']
# See: https://translate.zvo.cn/43086.html
service = 'client.edge'
# List of language ID to translate to, e.g. ["english", "chinese_simplified", "chinese_traditional", ...]
# See the full language list: https://api.translate.zvo.cn/language.json
languages = [
'english',
'chinese_simplified',
'chinese_traditional',
]
# Element IDs that needs to be ignored for translation
ignoreID = []
# Class names that need to be ignored for translation
ignoreClass = []
# Tag names that need to be ignored for translation
ignoreTag = ['title']
# Whether to detect the local language
# If your site itself is multilingual in Hugo, it is not recommended to enable this feature!
detectLocalLanguage = false

# FixIt Docs config
[docs]
minHugoVersion = "0.134.1"
Expand Down
1 change: 1 addition & 0 deletions data/projects.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- hugo-fixit/hugo-atom-feed
- hugo-fixit/cmpt-mdevtools
- hugo-fixit/cmpt-flyfish
- hugo-fixit/cmpt-translate
- hugo-fixit/hugo-json-feed
- hugo-fixit/shortcode-caniuse
- hugo-fixit/shortcode-docs-bookmark
Expand Down
1 change: 1 addition & 0 deletions data/projects.zh-cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- hugo-fixit/hugo-atom-feed
- hugo-fixit/cmpt-mdevtools
- hugo-fixit/cmpt-flyfish
- hugo-fixit/cmpt-translate
- hugo-fixit/hugo-json-feed
- hugo-fixit/shortcode-caniuse
- hugo-fixit/shortcode-docs-bookmark
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module github.com/hugo-fixit/docs
go 1.20

require (
github.com/hugo-fixit/FixIt v0.3.16-0.20241128061139-c06afaba2000 // indirect
github.com/hugo-fixit/component-projects v1.4.0 // indirect
github.com/hugo-fixit/FixIt v0.3.16-0.20241203093028-ac4418e24e70 // indirect
github.com/hugo-fixit/cmpt-translate v1.0.0 // indirect
github.com/hugo-fixit/component-projects v1.4.1 // indirect
github.com/hugo-fixit/shortcode-caniuse v1.1.3 // indirect
github.com/hugo-fixit/shortcode-rewards v1.0.4 // indirect
)
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
github.com/hugo-fixit/FixIt v0.3.16-0.20241128061139-c06afaba2000 h1:Y2euV0blmGLuW5FX/ug59p14L5XRqBjqPEvni8cO67k=
github.com/hugo-fixit/FixIt v0.3.16-0.20241128061139-c06afaba2000/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/component-projects v1.4.0 h1:Z9q+aY/ZBD4qcqcnPWNlGc/c7HDYu+5hj996TCTpRw0=
github.com/hugo-fixit/component-projects v1.4.0/go.mod h1:nXW0R37REwpfwUD1I4RtB5QW71vw66nRyB9uEpYxr+c=
github.com/hugo-fixit/FixIt v0.3.16-0.20241203093028-ac4418e24e70 h1:S0iSc/RBkisVf25Vt5FRg2NmJNXLzgGeS4nIbtmAd0c=
github.com/hugo-fixit/FixIt v0.3.16-0.20241203093028-ac4418e24e70/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/cmpt-translate v1.0.0 h1:litswWRiYJpM8aMgJZz4Ze3EelGcOhOvN3iMytbcgEw=
github.com/hugo-fixit/cmpt-translate v1.0.0/go.mod h1:JZ0STubquTlRgyyGhGPlt2s0KJ1gCa99+P8ltTwQRM4=
github.com/hugo-fixit/component-projects v1.4.1 h1:aSDOf9A8Z2AH8jBq/Xgaw5esm6OMFGDTZ/p2FDG9V1E=
github.com/hugo-fixit/component-projects v1.4.1/go.mod h1:nXW0R37REwpfwUD1I4RtB5QW71vw66nRyB9uEpYxr+c=
github.com/hugo-fixit/shortcode-caniuse v1.1.3 h1:U1YBJz5SI/d1BBQhHcD0eVgJdCcpzK2usSizPiu+a4w=
github.com/hugo-fixit/shortcode-caniuse v1.1.3/go.mod h1:RoPLFt+7uLui5rjvkC/qFGeo4nly5AzzwIID9SoDKNc=
github.com/hugo-fixit/shortcode-rewards v1.0.4 h1:62qCmcGvAJf+qa+8ofRX6jwMUXo6Q4+PQvlOtu0ZGBA=
Expand Down
1 change: 1 addition & 0 deletions hugo.work
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ use ../FixIt
use ../component-projects
use ../shortcode-caniuse
use ../shortcode-rewards
use ../cmpt-translate

0 comments on commit a92a1c1

Please sign in to comment.