Multilingual an' i18n
Fello' pirrates, be awarrre some stuff may not work fer us in this trrranslat'n. Like table of rrramblings, see'ng Merrrmaids, do'ng math or chemistrrry and stuff.
Th' Relearrrn theme be fully compat'ble wit' Cap'n Hugo multilingual mode.
It provides:
- Translat'n str'ns fer default values (English, Arabic, Simplified Chinese, Traditional Chinese, Dutch, Finnish (Suomi), French, German, Hindi, Indonesian, Italian, Japanese, Korean, Polish, Portuguese, Russian, Spanish, Turkish, Vietnamese). Feel free t' contribute!
- 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 config.toml
file.
For example wit' current English an' Piratized English website.
# 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 does not. You’ll see error reports 'n yer browsers console log fer each unsupported language. Currently unsupported be:
- Indonesian
- Polish
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 config.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 config.toml
[params]
# When us'n multilingual website, dis'ble th' switch language button.
disableLanguageSwitchingButton = true