Multilingual Mode

Doks is fully prepared for multilingual and i18n support.

On this page

Demo

  • Available soon

Configuration

Enable

In ./config/_default/params.toml, enable Multilinguage Mode:

  1. [options]
  2. ..
  3. multilingualMode = true
  4. ..

Set languages

In ./config/_default/config.toml, set languages:

  1. # Multilingual
  2. defaultContentLanguage = "en"
  3. disableLanguages = ["de", "nl"]
  4. # defaultContentLanguageInSubdir = true

Set language settings

In ./config/_default/languages.toml, set language settings (for each language):

  1. [en]
  2. languageName = "English"
  3. contentDir = "content/en"
  4. weight = 10
  5. [en.params]
  6. languageISO = "EN"
  7. [de]
  8. languageName = "German"
  9. contentDir = "content/de"
  10. weight = 15
  11. [de.params]
  12. languageISO = "DE"

Set menu entries

In ./config/_default/menus/menus.<ISO country code lowercase>.toml (so, e.g. in ./config/_default/menus/menus.en.toml), set menu entries (for each language).

Set translation strings

In ./i18n/<ISO country code lowercase>.toml (so, e.g. in ./i18n/en.toml), set translation strings (for each language).

Add content

In ./content.<ISO country code lowercase>/ (so, e.g. in ./content/en/), add content (for each language).

Build content

The content is build automatically with npm run start or npm run build.

  1. ..
  2. Start building sites
  3. hugo v0.88.1-5BC54738+extended windows/amd64 BuildDate=2021-09-04T09:39:19Z VendorInfo=gohugoio
  4. | EN | DE | NL
  5. -------------------+----+----+-----
  6. Pages | 29 | 7 | 24
  7. Paginator pages | 0 | 0 | 0
  8. Non-page files | 1 | 0 | 0
  9. Static files | 89 | 89 | 89
  10. Processed images | 0 | 0 | 0
  11. Aliases | 2 | 0 | 0
  12. Sitemaps | 2 | 1 | 1
  13. Cleaned | 0 | 0 | 0
  14. Built in 985 ms
  15. ..

Switch content

Multilingual Support

The language switch is part of the global navigation (available on all pages).

  • If the current page is available in the newly selected language, the corresponding page in the newly selected language is shown.
  • If the current page is not available in the newly selected language, the homepage of the newly selected language is shown.

Resources