diff --git a/assets/js/next-boot.js b/assets/js/next-boot.js index 1fe057c..c3123cd 100644 --- a/assets/js/next-boot.js +++ b/assets/js/next-boot.js @@ -60,7 +60,10 @@ NexT.boot.registerEvents = function() { NexT.boot.refresh = function() { NexT.utils.fmtSiteInfo(); - NexT.utils.registerLangSelect(); + + if (NexT.CONFIG.isMultiLang) { + NexT.utils.registerLangSelect(); + } if (!NexT.CONFIG.page.isPage) return; diff --git a/assets/js/utils.js b/assets/js/utils.js index 16430f0..e278601 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -523,12 +523,11 @@ NexT.utils = { optionsDom.style.opacity = '0'; optionsDom.style.transform = 'translateY(-10px)'; - const currentUrl = window.location.href; - const newUrl = currentUrl.replace(/(\/[^\/]+)?(\/[^\/]+)?$/, `/${langCode}$1$2`); - + let url = option.getAttribute('lang-url'); + setTimeout(() => { optionsDom.style.display = 'none'; - window.location.href = newUrl; + window.location.href = url; }, 300); }); }); diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 2ec80a4..63af6c9 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -23,6 +23,24 @@ theme: hugo-theme-next # Default laguage & code for website defaultContentLanguage: zh-cn languageCode: zh-CN +# 多语言配置 +# Multi-language settings +# languages: +# zh-cn: +# languageCode: zh-CN +# languageDirection: ltr +# languageName: "简体中文" +# weight: 1 +# en-us: +# languageCode: en-US +# languageDirection: ltr +# languageName: English +# weight: 2 +# fr-fr: +# languageCode: fr-FR +# languageDirection: ltr +# languageName: French +# weight: 2 # 是否包含中文,日语,韩文 # Whether contains Chinese, Japanese and Korean hasCJKLanguage: true @@ -376,10 +394,7 @@ params: # 站点底部设置 # Footer Settings # --------------------------------------------------------------- - footer: - # 启动谷歌翻译功能 - # Enable google translate in footer - translate: false + footer: # 站点开始年份,默认为当下时间的年份 # Specify the year when the site was setup. # If not defined, current year will be used. diff --git a/i18n/en.yaml b/i18n/en-us.yaml similarity index 100% rename from i18n/en.yaml rename to i18n/en-us.yaml diff --git a/i18n/fr.yaml b/i18n/fr-fr.yaml similarity index 100% rename from i18n/fr.yaml rename to i18n/fr-fr.yaml diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b4851e7..4fef69c 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -27,7 +27,7 @@ {{ end }} - {{ partial "widgets.html" . }} + {{ partialCached "widgets.html" . }}
{{ block "main" . }}{{ end }} @@ -38,6 +38,7 @@ diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 1756d3f..f69d2d6 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,23 +1,4 @@ {{ $ft := .Site.Params.footer }} -
- -
-
- - {{ .Site.Language.LanguageName }} - -
-
- {{ range .Site.Languages }} -
- - {{ .LanguageName }} -
- {{ end }} -
-
- -