web/translations: add fallback locale name to unnamed locales

This commit is contained in:
dumbmoron 2024-09-16 15:13:44 +00:00
parent d93e97e06b
commit 66479a9791
No known key found for this signature in database

View file

@ -7,7 +7,7 @@ import type {
LocalizationContent LocalizationContent
} from '$lib/types/i18n'; } from '$lib/types/i18n';
import languages from '$i18n/languages.json'; import _languages from '$i18n/languages.json';
const locFiles = import.meta.glob('$i18n/*/**/*.json'); const locFiles = import.meta.glob('$i18n/*/**/*.json');
const parsedLocfiles: StructuredLocfileInfo = {}; const parsedLocfiles: StructuredLocfileInfo = {};
@ -22,6 +22,8 @@ for (const [path, loader] of Object.entries(locFiles)) {
} }
const defaultLocale = 'en'; const defaultLocale = 'en';
const languages: Record<string, string> = _languages;
const config: Config<{ const config: Config<{
value?: string; value?: string;
formats?: string; formats?: string;
@ -30,6 +32,8 @@ const config: Config<{
}> = { }> = {
fallbackLocale: defaultLocale, fallbackLocale: defaultLocale,
translations: Object.keys(parsedLocfiles).reduce((obj, lang) => { translations: Object.keys(parsedLocfiles).reduce((obj, lang) => {
languages[lang] ??= `${lang} (missing name)`;
return { return {
...obj, ...obj,
[lang]: { languages } [lang]: { languages }