Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame contribute delete
676 Bytes
import { i18n } from "@lingui/core";
import dayjs from "dayjs";
import { dayjsLocales } from "./dayjs";
export const defaultLocale = "en-US";
export async function dynamicActivate(locale: string) {
try {
const { messages } = await import(`../locales/${locale}/messages.po`);
if (messages) {
i18n.loadAndActivate({ locale, messages });
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (dayjsLocales[locale]) {
dayjs.locale(await dayjsLocales[locale]());
}
} catch {
// eslint-disable-next-line lingui/no-unlocalized-strings
throw new Error(`Failed to load messages for locale: ${locale}`);
}
}