Skip to main content

Internationalization

Red Glare ships i18n scaffolding: a defaultLocale, a locales registry, a i18n.lang frontmatter field, and a language switcher in the header. UI strings (sidebar labels, "Edit this page", search placeholder, etc.) are translated for supported locales.

Current support

The integration ships built-in UI translations for English (en) and Spanish (es). Additional locales can be declared — pages render correctly — but UI chrome falls back to English until the package adds strings for your locale.

defaultLocale

Type: string · Default: 'en'

The default language of the site. Pages without a i18n.lang frontmatter value are assumed to be in this locale. The <html lang="..."> attribute on those pages is set from here.

redGlare({
  defaultLocale: 'en',
})

locales

Type: Record<string, { label: string }> · Optional

Registers additional locales. The key is the locale code (ISO 639-1 like en, es, fr — or with region, en-US, pt-BR). The value's label is the display string shown in the language switcher.

redGlare({
  defaultLocale: 'en',
  locales: {
    en: { label: 'English' },
    es: { label: 'Español' },
  },
})

The default locale should be declared in locales too so it appears in the switcher.

Per-page i18n.lang

In each page's frontmatter, set i18n.lang to the page's locale:

i18n:
  lang: es

The route's <html lang> is set from this value. Pages without a lang fall back to defaultLocale.

Language switcher

When two or more locales are configured, the header renders a dropdown language switcher. Clicking a locale navigates to the equivalent page in that language.

"Equivalent page" is resolved by convention — the switcher expects parallel file paths per locale, e.g.:

src/content/docs/
├── en/
│   └── guides/setup.md
└── es/
    └── guides/setup.md

The switcher swaps the locale prefix in the path when the user picks a language.

What's translated today

UI strings that ship with the integration:

Stringenes
"Edit this page"Edit this pageEditar esta página
"On this page"On this pageEn esta página
"Search"SearchBuscar
"Previous" / "Next"Previous / NextAnterior / Siguiente
"Skip to main content"Skip to main contentSaltar al contenido principal

Content itself is not translated automatically — you author each locale's markdown independently.

Not yet supported

  • Automatic locale routing fallback (serving /es/foo/ with the English page when Spanish is missing).
  • Right-to-left layout.
  • Pluralization rules in UI strings.

Filing these as feature requests is welcome. For now, author each locale's page tree in parallel and the rest of the chrome takes care of itself.

Red Glare

An official website of the Open source project

Looking for U.S. government information and services? Visit USA.gov