RefactKit ships with full internationalization support covering five locales and automatic RTL layout switching. Rather than using the fullDocumentation Index
Fetch the complete documentation index at: https://docs.refactkit.com/llms.txt
Use this file to discover all available pages before exploring further.
i18next instance directly, translations are loaded into a lightweight React context in src/i18n/context.tsx that exposes typed translation objects and a locale setter. This means you get TypeScript autocomplete on every translation key without any extra configuration.
Supported locales
| Locale | Language | Direction |
|---|---|---|
en | English | LTR |
fr | French | LTR |
es | Spanish | LTR |
pt | Portuguese | LTR |
ar | Arabic | RTL |
lk_locale) so the server can render the correct language on the first request — no flash of the wrong language during hydration.
How i18n works
src/i18n/index.ts defines the Locale type, the locale cookie name, and two functions:
getTranslations(locale)— returns the typed translation object for a given localegetServerLocale— a server function that reads the locale from the request cookie
src/i18n/context.tsx wraps these in a React context that any component can consume:
setLocale updates the React state, writes the cookie, and the useEffect updates the dir and lang attributes on <html> — which triggers the direction-aware font switch automatically.
Use translations in a component
CalluseI18n() to get the translation object t and the current locale:
t.key.path convention — traverse the nested translation object with dot notation. TypeScript will flag any missing or misspelled keys at compile time because t is typed as Translations (the shape of src/i18n/locales/en.ts).
Add a new translation key
Add the key to the English locale
Open
src/i18n/locales/en.ts — this file is the Translations type definition. Add your key in the appropriate namespace:Add the key to all other locales
Open each of the remaining locale files (
fr.ts, es.ts, pt.ts, ar.ts) and add the translated value for the same key. TypeScript will show a type error if any locale is missing a key that exists in en.ts.Add a new locale
Create the locale file
Create
src/i18n/locales/de.ts (or whichever language code you need) and export a complete translation object that matches the shape of en.ts:Register the locale in src/i18n/index.ts
Import the new locale and add it to the Also update the
locales map and the Locale type:detectLocale and getServerLocale functions to handle the new locale value from the cookie.Direction-aware fonts
The app automatically switches fonts based on the document direction:- LTR (English, French, Spanish, Portuguese): Google Sans Flex
- RTL (Arabic): Zain
data-font attribute on <html>. The useFont hook in src/hooks/use-font.ts manages this attribute and persists the user’s choice to localStorage:
Add a new font
Register the CSS variable
Add a
data-font selector to globals.css that sets the --font-family variable:Update the Font type in use-font.ts
Add the new font key to the
Font union type in src/hooks/use-font.ts:Locale detection: server vs. client
RefactKit reads the locale from two places depending on context:- Server:
getServerLocale()parses thelk_localecookie from the incoming request headers. Call this in your root route loader to passinitialLocaleto<I18nProvider>. - Client:
detectLocale()reads the same cookie viajs-cookie. This is used for the initial state on the client when SSR data is not available.
fr if no cookie is set. Change the fallback locale in src/i18n/index.ts if your default audience speaks a different language.
