2024-03-04 10:33:02 -06:00
|
|
|
import { Locale } from 'discord.js';
|
|
|
|
|
|
|
|
|
|
const LOCALES: Locale[number][] = ['en-US', 'es-ES'];
|
2024-03-03 22:13:22 -06:00
|
|
|
|
|
|
|
|
export type TranslationFragmentTree = {
|
|
|
|
|
[key: string]: TranslationFragment;
|
|
|
|
|
} & {
|
|
|
|
|
$?: string;
|
|
|
|
|
};
|
|
|
|
|
export type TranslationFragment = string | TranslationFragmentTree;
|
|
|
|
|
|
2024-03-04 10:33:02 -06:00
|
|
|
export const translations = Promise.all(
|
|
|
|
|
LOCALES.map(async (locale) => ({
|
|
|
|
|
locale,
|
|
|
|
|
translations: await import(`../../lang/${locale}.json`),
|
|
|
|
|
})),
|
|
|
|
|
).then(
|
|
|
|
|
(translations) =>
|
|
|
|
|
translations.reduce(
|
|
|
|
|
(table, { locale, translations }) => ({
|
|
|
|
|
...table,
|
|
|
|
|
[locale]: translations,
|
|
|
|
|
}),
|
|
|
|
|
{},
|
|
|
|
|
) as Record<Locale[number], TranslationFragment>,
|
|
|
|
|
);
|