Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit 8924d59

Browse files
add i18n
1 parent bda6e9b commit 8924d59

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,38 @@ menu:
6767
- name: Documentation
6868
url: /docs/
6969
weight: 2
70+
71+
72+
# Internationalization
73+
74+
defaultContentLanguage: en
75+
76+
# show language abbreviation in url. If you enable this option, remember to update image paths
77+
# defaultContentLanguageInSubdir: true
78+
languages:
79+
ar:
80+
contentDir: content/arabic
81+
languageName: عربى
82+
languagedirection: rtl
83+
title: مدونتي
84+
weight: 2
85+
en:
86+
contentDir: content/english
87+
languageName: English
88+
title: My project
89+
weight: 1
90+
esp:
91+
contentDir: content/spanish
92+
languageName: Español
93+
title: Mi proyecto
94+
weight: 2
95+
fr:
96+
contentDir: content/french
97+
languageName: Français
98+
title: Mon projet
99+
weight: 2
100+
pt-pt:
101+
contentDir: content/portuguese
102+
languageName: Português
103+
title: O meu blog
104+
weight: 3

i18n/en-US.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
home:
2+
other: Home

layouts/_default/baseof.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<body>
2222
{{ partial "navbar.html" . }}
2323
<main class="content">
24+
{{ partial "i18nlist.html" }}
25+
{{ partial "allLanguages.html" }}
2426
{{ block "main" . }}
2527
{{ end }}
2628
</main>

layouts/partials/allLanguages.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ul>
2+
{{ range $.Site.Home.AllTranslations }}
3+
<li><a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a></li>
4+
{{ end }}
5+
</ul>

layouts/partials/i18nlist.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{ if .IsTranslated }}
2+
<h4>{{ i18n "translations" }}</h4>
3+
<ul>
4+
{{ range .Translations }}
5+
<li>
6+
<a href="{{ .Permalink }}">{{ .Lang }}: {{ .Title }}{{ if .IsPage }} ({{ i18n "wordCount" . }}){{ end }}</a>
7+
</li>
8+
{{ end }}
9+
</ul>
10+
{{ end }}

0 commit comments

Comments
 (0)