Skip to content

Multiple languages

The engine routes by locale. One locale is the root: its pages are served without a prefix, and every other locale gets one.

Site.create "Docs"
|> Site.locales
    [
        Locale.root "en" |> Locale.withLabel "English"
        Locale.other "fr" |> Locale.withLabel "Français"
        Locale.other "ar" |> Locale.withLabel "العربية" |> Locale.rightToLeft
    ]

Where translations live

A directory named after a locale claims the pages inside it, and drops out of the route:

content/
├── guide/
│   └── setup.md        ->  /guide/setup/
└── fr/
    └── guide/
        └── setup.md    ->  /fr/guide/setup/

Both pages share a route key - guide/setup - and that is how the engine knows they are the same page in two languages. The language picker and the fallback below both work from that key.

With a single locale declared, fr/ is an ordinary directory.

Untranslated pages

When a page is missing from a locale, Nacara generates it from the default locale's content and marks it as untranslated. The theme says so at the top of the page:

Set Site.fallBackToDefaultLocale false to leave the page out instead.

The language picker

NavbarLocalePicker lists the locales and links to the translation of the page you are reading, not to the home page. A locale that has no translation of that page still appears, marked as such.

NavbarEnd = [ NavbarLocalePicker ]

Direction

Locale.rightToLeft sets dir="rtl" on the document for that locale. The theme's layout uses logical properties, so a right-to-left locale needs no stylesheet of its own.

Edit this page