Files
blitzkit/packages/i18n/src/strings.ts
T

68 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-09-27 15:38:37 -05:00
import { merge } from "ts-deepmerge";
import locales from "../locales.json";
import en from "../strings/en.json";
import es from "../strings/es.json";
import fr from "../strings/fr.json";
import ja from "../strings/ja.json";
import pl from "../strings/pl.json";
import pt from "../strings/pt.json";
import ru from "../strings/ru.json";
import uk from "../strings/uk.json";
import zh from "../strings/zh.json";
2025-01-14 14:38:41 -06:00
2025-01-15 20:14:05 -06:00
export type BlitzKitStrings = typeof en;
2025-01-14 14:38:41 -06:00
2025-09-27 15:38:37 -05:00
const stringsRaw: Record<string, TranslationTree> = {
en,
es,
fr,
ja,
pl,
pt,
ru,
uk,
zh,
};
2025-01-06 20:09:11 -06:00
2025-09-27 15:38:37 -05:00
export const STRINGS: Record<string, BlitzKitStrings> = {};
2025-01-15 20:14:05 -06:00
for (const locale in stringsRaw) {
2025-09-27 15:38:37 -05:00
if (locale === locales.default) {
STRINGS[locales.default] = stringsRaw[locales.default] as BlitzKitStrings;
2025-01-15 20:14:05 -06:00
continue;
}
2025-09-27 15:38:37 -05:00
const localeStrings = stringsRaw[locale];
STRINGS[locale] = merge(
stringsRaw[locales.default],
2026-02-18 16:36:12 -06:00
localeStrings,
2025-09-27 15:38:37 -05:00
) as BlitzKitStrings;
2025-01-15 20:14:05 -06:00
}
2025-09-27 15:38:37 -05:00
export const SUPPORTED_LOCALE_BLITZ_MAP: Record<string, string> = {
en: "en",
es: "es",
fr: "fr",
ja: "ja",
pt: "pt",
ru: "ru",
uk: "uk",
zh: "zh-Hans",
pl: "pl",
2025-01-15 20:14:05 -06:00
};
2025-09-27 15:38:37 -05:00
export const SUPPORTED_LOCALE_FLAGS: Record<string, string> = {
en: "🇺🇸",
es: "🇪🇸",
fr: "🇫🇷",
ja: "🇯🇵",
pt: "🇵🇹",
ru: "🇷🇺",
uk: "🇺🇦",
zh: "🇨🇳",
pl: "🇵🇱",
2025-01-15 20:14:05 -06:00
};
export type TranslationTree = { [key: string]: TranslationNode };
export type TranslationNode = string | TranslationTree;