web/translations: add fallback locale name to unnamed locales
This commit is contained in:
parent
d93e97e06b
commit
66479a9791
1 changed files with 5 additions and 1 deletions
|
@ -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 }
|
||||||
|
|
Loading…
Reference in a new issue