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, Romanian, 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

I18n menu I18n menu

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.

Avast

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

hugo.
defaultContentLanguage = 'en'

[languages]
  [languages.en]
    languageName = 'English'
    title = 'Hugo Relearrrn Theme'
    weight = 1

  [languages.pir]
    languageName = 'Arrr! Pirrrates'
    title = "Cap'n Hugo Relearrrn Theme"
    weight = 2
defaultContentLanguage: en
languages:
  en:
    languageName: English
    title: Cap'n Hugo Relearrrn Theme
    weight: 1
  pir:
    languageName: Arrr! Pirrrates
    title: Cap'n Hugo Relearrrn Theme
    weight: 2
{
   "defaultContentLanguage": "en",
   "languages": {
      "en": {
         "languageName": "English",
         "title": "Hugo Relearrrn Theme",
         "weight": 1
      },
      "pir": {
         "languageName": "Arrr! Pirrrates",
         "title": "Cap'n Hugo Relearrrn Theme",
         "weight": 2
      }
   }
}

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
  • Single file _index.md be split 'n two files:
    • 'n English: _index.md
    • 'n Piratized English: _index.pir.md
Ahoi

Be aware that only translated planks be displayed 'n menu. It’s not replaced wit' default language rrrambl'n.

Smarrrt Arrrse

Use slug frontmatter parameter t' translate urls too.

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.

Arrr

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.

hugo.
[params]
  additionalContentLanguage = ['en']
params:
  additionalContentLanguage:
  - en
{
   "params": {
      "additionalContentLanguage": [
         "en"
      ]
   }
}

As this be an array, ye can add multiple additional languages.

Avast

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

hugo.
[params]
  disableLanguageSwitchingButton = true
params:
  disableLanguageSwitchingButton: true
{
   "params": {
      "disableLanguageSwitchingButton": true
   }
}