Fix missing type support for i18n resources

Due to the change in 65a9a905be - moving to a json file - it wasn't ensured anymore that IsoLanguages contained the i18n language codes
This commit is contained in:
schroda
2026-01-30 21:46:20 +01:00
parent c5cdd347b7
commit edbbc81575
5 changed files with 47 additions and 37 deletions

View File

@@ -34,7 +34,7 @@ import { LibraryOptions } from '@/features/library/Library.types.ts';
import { MetadataThemeSettings } from '@/features/theme/AppTheme.types.ts';
import { TapZoneInvertMode } from '@/features/reader/tap-zones/TapZoneLayout.types.ts';
import { detectLocale, getISOLanguage } from '@/lib/ISOLanguageUtil.ts';
import { i18nResources } from '@/i18n';
import { I18nResourceCode, i18nResources } from '@/i18n';
import { toUniqueLanguageCodes } from '@/base/utils/Languages.ts';
export const APP_METADATA_KEY_PREFIX = 'webUI';
@@ -385,7 +385,7 @@ export const APP_METADATA: Record<
toConstrainedValue: (value: string) => {
const locale = getISOLanguage(value)?.isoCode;
if (!locale || !i18nResources.includes(locale)) {
if (!locale || !i18nResources.includes(locale as I18nResourceCode)) {
return detectLocale();
}

View File

@@ -10,7 +10,14 @@ import { i18n } from '@lingui/core';
import { detectLocale, SELECTED_LANGUAGE_CODE_KEY } from '@/lib/ISOLanguageUtil.ts';
import { AppStorage } from '@/lib/storage/AppStorage.ts';
// This array is auto-generated by tools/scripts/weblate/generatei18nResources.ts. Do not edit manually.
/**
* Keys have to match {@link IsoLanguages} codes, they're used for showing the language name in the dropdown in the {@link Settings}.<br/>
* In case there is no language code for the key in {@link IsoLanguages}, the corresponding language has to be added
*
* **IMPORTANT:**
*
* This is generated by the `i18n:gen-resources` script
*/
export const i18nResources = [
'de',
'en',

View File

@@ -1,23 +0,0 @@
{
"comment": "!!!IMPORTANT!!!: 'locales' is auto generated by tools/scripts/weblate/generatei18nResources.ts. Do not edit manually.",
"locales": [
"de",
"en",
"es",
"fa",
"fr",
"hu",
"it",
"ja",
"ko",
"pl",
"pt",
"ru",
"ta",
"tr",
"vi",
"zh_Hans",
"zh_Hant"
],
"defaultLocale": "en"
}