website/dictionaries.ts

12 lines
494 B
TypeScript
Raw Permalink Normal View History

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