Supported locales
| Locale | Language | Direction | Default font |
|---|---|---|---|
en | English | LTR | Google Sans Flex |
fr | French | LTR | Google Sans Flex |
es | Spanish | LTR | Google Sans Flex |
pt | Portuguese | LTR | Google Sans Flex |
ar | Arabic | RTL | Zain |
document.dir. When the locale is ar, the --font-family CSS variable resolves to "Zain". All other locales use "Google Sans Flex Variable". You can override this per-user through the Appearance settings page.
Use translations in a component
Import theuseI18n hook from @/i18n/context to access the translation object, the active locale code, and the text direction string:
t object is fully typed — TypeScript infers the shape from src/i18n/locales/en.ts, which serves as the canonical reference for all translation keys. Every other locale file is typed against this shape using Translations from en.ts.
Switch the active locale
CallsetLocale() from useI18n() with a valid locale code. It updates React state, writes the new value to the lk_locale cookie (valid for 365 days), and flips document.documentElement.dir — all in one call:
How server-side locale detection works
During SSR, the root layout callsgetServerLocale() — a server function in src/i18n/index.ts — which reads the lk_locale cookie from the request headers before any React rendering happens:
initialLocale to <I18nProvider> in the root layout, which sets the initial state before hydration. On the client, the provider keeps locale in React state and propagates changes via context.
Add a new locale
Create the locale file
Create TypeScript will show a type error for any missing key, so you cannot accidentally ship an incomplete translation.
src/i18n/locales/de.ts (or any ISO 639-1 code). Import the Translations type from en.ts to ensure your file includes every required key:Register the locale in index.ts
Import the new file and add it to the Also update
locales map and the Locale union type:getServerLocale() to handle the new cookie value:Add a font if needed
If the new language requires a different typeface (e.g., a CJK or Arabic-script font), import it in For LTR languages that share the Latin script, no font change is needed — they will inherit
src/styles/globals.css and add a direction or data-font rule:"Google Sans Flex Variable" automatically.The
getServerLocale() server function defaults to 'fr' when no cookie is present. If you want a different default language for new visitors, change the fallback value in src/i18n/index.ts.