mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-23 21:38:07 +01:00
23 lines
456 B
TypeScript
23 lines
456 B
TypeScript
|
export interface LocaleData {
|
||
|
locale: string;
|
||
|
messages: Record<string, string>;
|
||
|
}
|
||
|
|
||
|
let loadedLocale: LocaleData;
|
||
|
|
||
|
export function setLocale(locale: LocaleData) {
|
||
|
loadedLocale = locale;
|
||
|
}
|
||
|
|
||
|
export function getLocale() {
|
||
|
if (!loadedLocale && process.env.NODE_ENV === 'development') {
|
||
|
throw new Error('getLocale() called before any locale has been set');
|
||
|
}
|
||
|
|
||
|
return loadedLocale;
|
||
|
}
|
||
|
|
||
|
export function isLocaleLoaded() {
|
||
|
return !!loadedLocale;
|
||
|
}
|