mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 07:53:41 +01:00
9e66c07be7
Port b0780cfeed
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
22 lines
456 B
TypeScript
22 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;
|
|
}
|