-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add multilingual mode support (#241)
BREAKING CHANGE: Layout file renamed ´layouts/partials/page-footer.html → layouts/partials/menu-nextprev.html`. If you use overrides, you might need to change the filenames as well.
- Loading branch information
Showing
88 changed files
with
437 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ KaTeX | |
katex | ||
Theming | ||
Favicon[s]? | ||
UI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
en: | ||
languageName: "English" | ||
contentDir: "content/en" | ||
weight: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
geekdocToC: 3 | ||
geekdocTagsToMenu: true | ||
|
||
geekdocRepo: https://github.com/thegeeklab/hugo-geekdoc | ||
geekdocEditPath: edit/main/exampleSite/content | ||
|
||
geekdocSearch: true | ||
geekdocSearchShowParent: true | ||
|
||
geekdocLegalNotice: https://thegeeklab.de/legal-notice/#contact-information | ||
geekdocPrivacyPolicy: https://thegeeklab.de/legal-notice/#privacy-policy | ||
|
||
geekdocImageLazyLoading: true | ||
geekdocDarkModeDim: true |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
title: Multilingual | ||
resources: | ||
- name: translation-available | ||
src: images/translation-available.png | ||
title: "" | ||
--- | ||
|
||
{{< toc >}} | ||
|
||
Hugo supports the creation of websites with multiple languages. In this post we will explain how to get configure Multilingual Mode with this theme. | ||
|
||
## Configuration | ||
|
||
### Languages | ||
|
||
You need to set a default language and configure at least two different languages used by your site to your configuration file at `config.toml`: | ||
|
||
```Toml | ||
defaultContentLanguage = "en" | ||
|
||
[languages.en] | ||
languageName = "English" | ||
contentDir = "content/en" | ||
weight = 10 | ||
|
||
[languages.de] | ||
languageName = "German" | ||
contentDir = "content/de" | ||
weight = 20 | ||
``` | ||
|
||
### Translation Strings | ||
|
||
To customize translation strings used by the theme you can create a file `i18n/<languagecode>.toml` for every language you want to use e.g. `i18n/en.toml`. You can lookup all used strings in the [default](https://github.com/thegeeklab/hugo-geekdoc/blob/main/i18n/en.yaml) translation file. | ||
|
||
### Menus | ||
|
||
For the [Bundle Menu](/usage/menus/#bundle-menu) as well as for the [Extra Header Menu](/usage/menus/#extra-header-menu) you can translate the name within the data file of the menu: | ||
|
||
```YAML | ||
--- | ||
more: | ||
# If `name` is a text, this text will be used as name for each language. | ||
- name: News | ||
ref: "/#" | ||
icon: "gdoc_notification" | ||
# To translate the name you can add a sub-item per language. Important: If you miss a language key | ||
# that is configured in the languages list of your `config.toml` the name will be empty for this language! | ||
- name: | ||
en: Releases | ||
de: Veröffentlichung | ||
ref: "https://github.com/thegeeklab/hugo-geekdoc/releases" | ||
external: true | ||
icon: "gdoc_download" | ||
``` | ||
## Add Content | ||
To translate your content you need to create a directory `content/<languagecode>/` for each language you want to use e.g. `content/en/`. This language directories will hold the translated pages for the particular language. | ||
|
||
## Switch Content | ||
|
||
If you have configured at least two different languages, the language switcher will be enabled in the UI automatically. The switcher is as part of the header menu and displayed on all pages. | ||
|
||
{{< columns >}} | ||
|
||
[![Beach Color Palette](images/translation-available.png)](images/translation-available.png) | ||
|
||
On pages for which a translation is available it will be displayed in the selection list and links to the translated page. | ||
|
||
<---> | ||
|
||
[![Beach Color Palette](images/translation-not-available.png)](images/translation-not-available.png) | ||
|
||
Pages without a translation will be displayed in the selection list as well but are marked with an asterisk and link to the start page of the respective language. | ||
|
||
{{< /columns >}} |
Binary file added
BIN
+58.4 KB
exampleSite/content/en/features/multilingual/images/translation-available.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.8 KB
exampleSite/content/en/features/multilingual/images/translation-not-available.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
edit_page: Seite bearbeiten | ||
|
||
nav_navigation: Navigation | ||
nav_tags: Tags | ||
nav_more: Weitere | ||
nav_top: Nach oben | ||
|
||
form_placeholder_search: Suchen | ||
|
||
error_page_title: Verlaufen? Keine Sorge | ||
error_message_title: Verlaufen? | ||
error_message_code: Fehler 404 | ||
error_message_text: > | ||
Wir können die Seite nach der Du gesucht hast leider nicht finden. Keine Sorge, | ||
wir bringen Dich zurück zur <a class="gdoc-error__link" href="{{ . }}">Startseite</a>. | ||
button_toggle_dark: Wechsel zwischen Dunkel/Hell/Auto Modus | ||
button_nav_open: Navigation öffnen | ||
button_nav_close: Navigation schließen | ||
button_menu_open: Menüband öffnen | ||
button_menu_close: Menüband schließen | ||
button_homepage: Zurück zur Startseite | ||
|
||
title_anchor_prefix: "Link zu:" | ||
|
||
posts_read_more: Ganzen Artikel lesen | ||
posts_read_time: | ||
one: "Eine Minute Lesedauer" | ||
other: "{{ . }} Minuten Lesedauer" | ||
posts_update_prefix: Aktualisiert am | ||
|
||
footer_build_with: > | ||
Entwickelt mit <a href="https://gohugo.io/" class="gdoc-footer__link">Hugo</a> und | ||
<svg class="icon gdoc_heart"><use xlink:href="#gdoc_heart"></use></svg> | ||
footer_legal_notice: Impressum | ||
footer_privacy_policy: Datenschutzerklärung | ||
|
||
language_switch_no_tranlation_prefix: "Seite nicht übersetzt:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
edit_page: Edit page | ||
|
||
nav_navigation: Navigation | ||
nav_tags: Tags | ||
nav_more: More | ||
nav_top: Back to top | ||
|
||
form_placeholder_search: Search | ||
|
||
error_page_title: Lost? Don't worry | ||
error_message_title: Lost? | ||
error_message_code: Error 404 | ||
error_message_text: > | ||
Seems like what you are looking for can't be found. Don't worry, we can | ||
bring you back to the <a class="gdoc-error__link" href="{{ . }}">homepage</a>. | ||
button_toggle_dark: Toggle Dark/Light/Auto mode | ||
button_nav_open: Open Navigation | ||
button_nav_close: Close Navigation | ||
button_menu_open: Open Menu Bar | ||
button_menu_close: Close Menu Bar | ||
button_homepage: Back to homepage | ||
|
||
title_anchor_prefix: "Anchor to:" | ||
|
||
posts_read_more: Read full post | ||
posts_read_time: | ||
one: "One minute to read" | ||
other: "{{ . }} minutes to read" | ||
posts_update_prefix: Updated on | ||
|
||
footer_build_with: > | ||
Built with <a href="https://gohugo.io/" class="gdoc-footer__link">Hugo</a> and | ||
<svg class="icon gdoc_heart"><use xlink:href="#gdoc_heart"></use></svg> | ||
footer_legal_notice: Legal Notice | ||
footer_privacy_policy: Privacy Policy | ||
|
||
language_switch_no_tranlation_prefix: "Page not translated:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.