1
0

i18n.ts 1.0 KB

1234567891011121314151617181920212223242526272829
  1. import { defineI18n } from 'fumadocs-core/i18n';
  2. // Directory-based i18n: content lives in `content/docs/{locale}/...`.
  3. // `fallbackLanguage` defaults to `defaultLanguage` ('en'), so untranslated
  4. // pages transparently serve English instead of 404ing.
  5. export const i18n = defineI18n({
  6. defaultLanguage: 'en',
  7. languages: ['en', 'fa', 'ru', 'zh'],
  8. parser: 'dir',
  9. // English keeps canonical `/docs/...`; other locales are prefixed `/fa/...`.
  10. hideLocale: 'default-locale',
  11. });
  12. export type Locale = (typeof i18n.languages)[number];
  13. // Display names for the language switcher (in their own script).
  14. export const locales: { locale: Locale; name: string }[] = [
  15. { locale: 'en', name: 'English' },
  16. { locale: 'fa', name: 'فارسی' },
  17. { locale: 'ru', name: 'Русский' },
  18. { locale: 'zh', name: '中文' },
  19. ];
  20. // Right-to-left locales (Persian). Drives `<html dir>` and `rtl:` variants.
  21. const rtlLocales = new Set<string>(['fa']);
  22. export function localeDirection(locale: string): 'rtl' | 'ltr' {
  23. return rtlLocales.has(locale) ? 'rtl' : 'ltr';
  24. }