Open History to see the last commit
1import { initializeGT } from "gt-react";
2
3import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from "./locales";
4
5// English is the source text, so it never loads a chunk.
6async function loadTranslations(locale: string): Promise<unknown> {
7 if (locale === DEFAULT_LOCALE) return {};
8 const module: { default: unknown } = await import(`./translations/${locale}.json`);
9 return module.default;
10}
11
12/** Sets up GT's singletons. `<I18nProvider>` names the locale and GT loads its catalog. */
13export function initializeI18n(): void {
14 initializeGT({
15 defaultLocale: DEFAULT_LOCALE,
16 locales: [...SUPPORTED_LOCALES],
17 loadTranslations,
18 });
19}