Multilingual an' i18n
Th' Relearrrn theme be fully compat'ble wit' Cap'n Hugo multilingual mode.
- Avail'ble languages: Arabic, Simplified Chinese, Traditional Chinese, Czech, Dutch, English, Finnish, French, German, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Polish, Portuguese, Russian, Spanish, Swahili, Turkish, Vietnamese. Feel free t' contribute!
- Full support fer languages written right t' left
- Automatic menu generat'n from multilingual rrrambl'n
- In-browser language switch'n
Basic configurat'n
Aft learn'n how Cap'n Hugo handle multilingual websites, define yer languages 'n yer hugo.toml
file.
For example wit' current English an' Piratized English website.
Make sure yer default language be defined as th' first one 'n th' [languages]
array, as th' theme needs t' make assumpt'ns on it
# English be th' default language
defaultContentLanguage = "en"
[languages]
[languages.en]
title = "Hugo Relearrrn Theme"
weight = 1
languageName = "English"
[languages.pir]
title = "Cap'n Hugo Relearrrn Theme"
weight = 2
languageName = "Arrr! Pirrrates"
Then, fer each new plank, append th' id o' th' language t' th' file.
- Single file
my-page.md
be split 'n two files:- 'n English:
my-page.md
- 'n Piratized English:
my-page.pir.md
- 'n English:
- Single file
_index.md
be split 'n two files:- 'n English:
_index.md
- 'n Piratized English:
_index.pir.md
- 'n English:
Be aware that only translated planks be displayed 'n menu. It’s not replaced wit' default language rrrambl'n.
Use slug frontmatter parameter t' translate urls too.
Search
In case each page’s rrrambl'n be written 'n one single language only, th' above configurat'n will already configure th' site’s search functionality correctly.
Although th' theme supports a wide variety o' supported languages, th' site’s search via th' Lunr search library does not. You’ll see error reports 'n yer browsers console log fer each unsupported language. Currently unsupported be:
- Czech
- Indonesian
- Polish
- Swahili
Search wit' mixed language support
In case yer page’s rrrambl'n contains text 'n multiple languages (e.g. ye be writ'n a Russian documentat'n fer yer english API), ye can add those languages t' yer hugo.toml
t' broaden search.
[params]
additionalContentLanguage = [ "en" ]
As this be an array, ye can add multiple additional languages.
Keep 'n mind that th' language code required here, be th' base language code. E.g. if ye have additional rrrambl'n 'n zh-CN
, ye have t' add just zh
t' this parameter.
Overwrite translat'n str'ns
Translat'ns str'ns be used fer common default values used 'n th' theme (Edit button, Search placeholder an' so on). Translat'ns be avail'ble 'n English an' Piratized English but ye may use another language or want t' override default values.
T' override these values, create a new file 'n yer local i18n folder i18n/<idlanguage>.toml
an' inspire yourself from th' theme themes/hugo-theme-relearn/i18n/en.toml
Dis'ble language switch'n
Switch'n th' language 'n th' browser be a great feature, but fer some reasons ye may want t' dis'ble it.
Just set disableLanguageSwitchingButton=true
'n yer hugo.toml
[params]
# When us'n multilingual website, dis'ble th' switch language button.
disableLanguageSwitchingButton = true