website/dictionaries.ts

13 lines
489 B
TypeScript
Raw Normal View History

2024-09-10 10:23:43 +03:00
import 'server-only';
import type { Locale } from './i18n-config';
2024-06-17 20:24:51 +03:00
// We enumerate all dictionaries here for better linting and typescript support
// We also get the default import for cleaner types
const dictionaries = {
2024-09-10 10:23:43 +03:00
en: () => import('./dictionaries/en.json').then((module) => module.default),
bg: () => import('./dictionaries/bg.json').then((module) => module.default),
2024-06-17 20:24:51 +03:00
};
export const getDictionary = async (locale: Locale) =>
2024-09-10 10:23:43 +03:00
dictionaries[locale]?.() ?? dictionaries.en();