Improve i18n resource typing

This commit is contained in:
schroda
2024-04-24 23:56:06 +02:00
parent a7cafb59a4
commit 082f923e10
2 changed files with 6 additions and 4 deletions

View File

@@ -33,7 +33,9 @@ export const i18nResources = [
'vi', 'vi',
'zh_Hans', 'zh_Hans',
'zh_Hant', 'zh_Hant',
]; ] as const;
export type I18nResourceCode = (typeof i18nResources)[number];
export const i18n = use(initReactI18next) export const i18n = use(initReactI18next)
.use(HttpBackend) .use(HttpBackend)

View File

@@ -6,9 +6,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
export const loadDefaultDayJsLocale = () => import('dayjs/locale/en.js'); import { I18nResourceCode } from '@/i18n';
export type ISOLanguageCode = string; export const loadDefaultDayJsLocale = () => import('dayjs/locale/en.js');
export type ISOLanguage = { export type ISOLanguage = {
name: string; name: string;
@@ -17,7 +17,7 @@ export type ISOLanguage = {
}; };
// full list: https://github.com/meikidd/iso-639-1/blob/master/src/data.js // full list: https://github.com/meikidd/iso-639-1/blob/master/src/data.js
export const ISOLanguages: Record<ISOLanguageCode, ISOLanguage> = { export const ISOLanguages: { [languageCode in I18nResourceCode]: ISOLanguage } & Record<string, ISOLanguage> = {
// ############################# // #############################
// ### ### // ### ###
// ### START: manually added ### // ### START: manually added ###