Files
cloud-host/frontend/src/i18n/config.ts
T
keyhan 34993d417f Add i18n foundation (fa-IR/en-US) and localize landing + auth.
Introduce path-prefixed locale routing under app/[lang] with a middleware
that detects locale from cookie/Accept-Language (default fa-IR) and
redirects. Add fa-IR (source of truth) and en-US dictionaries, a server
getDictionary, a client I18nProvider/useT, locale-aware Link + router
helpers, and a language switcher. The root [lang] layout sets html
lang/dir and the per-locale font (Peyda for fa, Inter for en).

Landing sections and the login/register/auth shell now read all copy from
the dictionaries; dashboard localization follows in a later commit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 12:05:03 +03:30

29 lines
862 B
TypeScript

// Supported locales for the app. fa-IR is the default (Persian, RTL); en-US is
// the secondary (English, LTR). Routing is path-prefixed: /fa-IR/... , /en-US/...
export const locales = ['fa-IR', 'en-US'] as const;
export type Locale = (typeof locales)[number];
export const defaultLocale: Locale = 'fa-IR';
export const localeDirection: Record<Locale, 'rtl' | 'ltr'> = {
'fa-IR': 'rtl',
'en-US': 'ltr',
};
// Short, human-facing labels for the language switcher.
export const localeNames: Record<Locale, string> = {
'fa-IR': 'فارسی',
'en-US': 'English',
};
export const LOCALE_COOKIE = 'NEXT_LOCALE';
export function isLocale(value: string | undefined | null): value is Locale {
return !!value && (locales as readonly string[]).includes(value);
}
export function dirFor(locale: Locale): 'rtl' | 'ltr' {
return localeDirection[locale];
}