[Glitch] Upgrade to typescript-eslint
v6
Port a7253075d1
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@ -3,15 +3,19 @@ export interface LocaleData {
|
||||
messages: Record<string, string>;
|
||||
}
|
||||
|
||||
let loadedLocale: LocaleData;
|
||||
let loadedLocale: LocaleData | undefined;
|
||||
|
||||
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');
|
||||
export function getLocale(): LocaleData {
|
||||
if (!loadedLocale) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
throw new Error('getLocale() called before any locale has been set');
|
||||
} else {
|
||||
return { locale: 'unknown', messages: {} };
|
||||
}
|
||||
}
|
||||
|
||||
return loadedLocale;
|
||||
|
@ -6,6 +6,7 @@ import { isLocaleLoaded, setLocale } from './global_locale';
|
||||
const localeLoadingSemaphore = new Semaphore(1);
|
||||
|
||||
export async function loadLocale() {
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- we want to match empty strings
|
||||
const locale = document.querySelector<HTMLElement>('html')?.lang || 'en';
|
||||
|
||||
// We use a Semaphore here so only one thing can try to load the locales at
|
||||
|
Reference in New Issue
Block a user