Skip to content

Commit

Permalink
Fix locales loading
Browse files Browse the repository at this point in the history
  • Loading branch information
renchap committed Sep 22, 2023
1 parent e0af45f commit 2f82d63
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app/javascript/mastodon/locales/load_locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { isLocaleLoaded, setLocale } from './global_locale';

const localeLoadingSemaphore = new Semaphore(1);

const localeFiles = import.meta.glob<LocaleData['messages']>([
'./locales/*.json',
]);
const localeFiles = import.meta.glob<LocaleData['messages']>(['./*.json']);

export async function loadLocale() {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- we want to match empty strings
Expand All @@ -22,9 +20,9 @@ export async function loadLocale() {
if (isLocaleLoaded()) return;

// If there is no locale file, then fallback to english
const localeFile = Object.hasOwn(localeFiles, '`./locales/${locale}.json`')
? localeFiles[`./locales/${locale}.json`]
: localeFiles[`./locales/en.json`];
const localeFile = Object.hasOwn(localeFiles, '`./${locale}.json`')
? localeFiles[`./${locale}.json`]
: localeFiles[`./en.json`];

const localeData = await localeFile();

Expand Down

0 comments on commit 2f82d63

Please sign in to comment.