2021-08-25 11:33:29 +00:00
+++
title = "Multilingual and i18n"
weight = 30
+++
2017-08-20 15:10:29 +00:00
2021-09-11 13:46:14 +00:00
The Relearn theme is fully compatible with Hugo multilingual mode.
2017-08-20 15:10:29 +00:00
It provides:
2021-09-11 13:46:14 +00:00
- Translation strings for default values (English, Arabic, Dutch, Piratized English, German, Hindi, Indonesian, Japanese, Piratized English, Portuguese, Russian, Simplified Chinese, Spanish, Turkish). Feel free to contribute!
2017-08-20 15:10:29 +00:00
- Automatic menu generation from multilingual content
- In-browser language switching
2021-09-11 13:46:14 +00:00
![I18n menu ](/cont/i18n/images/i18n-menu.gif )
2017-08-20 15:10:29 +00:00
## Basic configuration
After learning [how Hugo handle multilingual websites ](https://gohugo.io/content-management/multilingual ), define your languages in your `config.toml` file.
2021-09-11 13:46:14 +00:00
For example with current English and Piratized English website.
2017-08-20 15:10:29 +00:00
```toml
# English is the default language
defaultContentLanguage = "en"
[Languages]
[Languages.en]
2021-06-30 12:56:06 +00:00
title = "Documentation for Hugo Relearn Theme"
2017-08-20 15:10:29 +00:00
weight = 1
languageName = "English"
2021-09-11 13:46:14 +00:00
[Languages.en-pir]
title = "Documentat'n fer Cap'n Hugo Relearrrn Theme"
2017-08-20 15:10:29 +00:00
weight = 2
2021-09-11 13:46:14 +00:00
languageName = "Arrr! Pirrrates"
2017-08-20 15:10:29 +00:00
```
Then, for each new page, append the *id* of the language to the file.
- Single file `my-page.md` is split in two files:
2021-09-11 13:46:14 +00:00
- in English: `my-page.md`
- in Piratized English: `my-page.en-pir.md`
2017-08-20 15:10:29 +00:00
- Single file `_index.md` is split in two files:
2021-09-11 13:46:14 +00:00
- in English: `_index.md`
- in Piratized English: `_index.en-pir.md`
2017-08-20 15:10:29 +00:00
{{% notice info %}}
Be aware that only translated pages are displayed in menu. It's not replaced with default language content.
{{% /notice %}}
{{% notice tip %}}
Use [slug ](https://gohugo.io/content-management/multilingual/#translate-your-content ) Front Matter parameter to translate urls too.
{{% /notice %}}
2017-08-20 20:29:35 +00:00
## Overwrite translation strings
2017-08-20 15:10:29 +00:00
2021-09-11 13:46:14 +00:00
Translations strings are used for common default values used in the theme (*Edit this page* button, *Search placeholder* and so on). Translations are available in English and Piratized English but you may use another language or want to override default values.
2017-08-20 15:10:29 +00:00
2021-08-23 21:51:52 +00:00
To override these values, create a new file in your local i18n folder `i18n/<idlanguage>.toml` and inspire yourself from the theme `themes/hugo-theme-relearn/i18n/en.toml`
2017-08-20 15:10:29 +00:00
## Disable language switching
2021-08-23 21:51:52 +00:00
Switching the language in the browser is a great feature, but for some reasons you may want to disable it.
2017-08-20 15:10:29 +00:00
Just set `disableLanguageSwitchingButton=true` in your `config.toml`
```toml
[params]
# When using mulitlingual website, disable the switch language button.
disableLanguageSwitchingButton = true
2017-08-20 20:29:35 +00:00
```