Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

initializeI18n.ts

19 lines642 Bytes

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;
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 });