Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xianmin/hugo-theme-jane.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaform <shaform@gmail.com>2018-07-12 12:40:24 +0300
committerShaform <shaform@gmail.com>2018-07-13 09:10:19 +0300
commit7877f19b078b86bec75152d788d20bceaf221087 (patch)
treed7dc7cade40eeadbcbb6329415e4c2a0aaa06c41
parentb9b45d27251c23772b0e5cf04d707f08a61f6595 (diff)
add basic language chooser on menu
-rw-r--r--dev-config.toml3
-rw-r--r--exampleSite/config.toml3
-rw-r--r--i18n/en.yaml3
-rw-r--r--i18n/es.yaml3
-rw-r--r--i18n/fr.yaml3
-rw-r--r--i18n/pt.yaml3
-rw-r--r--i18n/ru.yaml3
-rw-r--r--i18n/zh-cn.yaml3
-rw-r--r--i18n/zh-tw.yaml3
-rw-r--r--layouts/partials/header.html18
10 files changed, 45 insertions, 0 deletions
diff --git a/dev-config.toml b/dev-config.toml
index ccf032b..e4822b0 100644
--- a/dev-config.toml
+++ b/dev-config.toml
@@ -129,6 +129,9 @@ defaultContentLanguage = "en" # Default language to use (if you setup multiling
# show word count and read time ? # 是否显示字数统计与阅读时间
moreMeta = true
+ # show language chooser in menu
+ showMenuLanguageChooser = true
+
# 一些全局开关,你也可以在每一篇内容的 front matter 中针对单篇内容关闭或开启某些功能,在 archetypes/default.md 查看更多信息。
# Some global options, you can also close or open something in front matter for a single post, see more information from `archetypes/default.md`.
toc = true # 是否开启目录
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index d556a92..b89d9c5 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -82,6 +82,9 @@ defaultContentLanguage = "en" # Default language to use
# show word count and read time ? # 是否显示字数统计与阅读时间
moreMeta = true
+ # show language chooser in menu
+ showMenuLanguageChooser = true
+
# 一些全局开关,你也可以在每一篇内容的 front matter 中针对单篇内容关闭或开启某些功能,在 archetypes/default.md 查看更多信息。
# Some global options, you can also close or open something in front matter for a single post, see more information from `archetypes/default.md`.
toc = true # 是否开启目录
diff --git a/i18n/en.yaml b/i18n/en.yaml
index 1eb0487..ce6ede9 100644
--- a/i18n/en.yaml
+++ b/i18n/en.yaml
@@ -98,3 +98,6 @@
- id: read_fr
translation: Lire en français
+
+- id: language
+ translation: Language
diff --git a/i18n/es.yaml b/i18n/es.yaml
index 2403562..987dcf6 100644
--- a/i18n/es.yaml
+++ b/i18n/es.yaml
@@ -95,3 +95,6 @@
- id: read_pt
translation: Leia em português
+
+- id: language
+ translation: Lenguaje
diff --git a/i18n/fr.yaml b/i18n/fr.yaml
index e60b7bd..8c19b45 100644
--- a/i18n/fr.yaml
+++ b/i18n/fr.yaml
@@ -98,3 +98,6 @@
- id: read_en
translation: Read in english
+
+- id: language
+ translation: Langage
diff --git a/i18n/pt.yaml b/i18n/pt.yaml
index 8c1468f..7d23460 100644
--- a/i18n/pt.yaml
+++ b/i18n/pt.yaml
@@ -98,3 +98,6 @@
- id: read_fr
translation: Lire en français
+
+- id: language
+ translation: Linguagem
diff --git a/i18n/ru.yaml b/i18n/ru.yaml
index 36e6b42..edf5295 100644
--- a/i18n/ru.yaml
+++ b/i18n/ru.yaml
@@ -98,3 +98,6 @@
- id: read_fr
translation: Lire en français
+
+- id: language
+ translation: Язык
diff --git a/i18n/zh-cn.yaml b/i18n/zh-cn.yaml
index 241f9cc..8e4d570 100644
--- a/i18n/zh-cn.yaml
+++ b/i18n/zh-cn.yaml
@@ -98,3 +98,6 @@
- id: read_fr
translation: Lire en français
+
+- id: language
+ translation: 语言
diff --git a/i18n/zh-tw.yaml b/i18n/zh-tw.yaml
index d115f2f..4cfd3b9 100644
--- a/i18n/zh-tw.yaml
+++ b/i18n/zh-tw.yaml
@@ -98,3 +98,6 @@
- id: read_fr
translation: Lire en français
+
+- id: language
+ translation: 語言
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index e143225..60f97bb 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -38,5 +38,23 @@
</li>
{{ end }}
+ {{ if and (gt (len .Site.Home.AllTranslations) 1) (.Site.Params.showMenuLanguageChooser | default false ) }}
+ {{- $.Scratch.Set "language" .Language -}}
+ <li class="menu-item">
+ <!-- drop down navigation MENU -->
+ <a class="menu-item-link menu-parent" href="{{ .URL | absLangURL | safeURL }}">{{ i18n "language" }}</a>
+ <ul class="submenu">
+ {{ range .Site.Home.AllTranslations }}
+ <li>
+ {{ if eq ($.Scratch.Get "language") .Language }}
+ <a href="{{ .Permalink }}"><strong>{{ .Language.LanguageName }}</strong></a>
+ {{ else }}
+ <a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
+ {{ end }}
+ </li>
+ {{ end }}
+ </ul>
+ </li>
+ {{ end }}
</ul>
</nav>