diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 1fab0ca4..fba29835 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -33,7 +33,9 @@ export const i18nResources = [ 'vi', 'zh_Hans', 'zh_Hant', -]; +] as const; + +export type I18nResourceCode = (typeof i18nResources)[number]; export const i18n = use(initReactI18next) .use(HttpBackend) diff --git a/src/util/isoLanguages.ts b/src/util/isoLanguages.ts index 1859f558..31276278 100644 --- a/src/util/isoLanguages.ts +++ b/src/util/isoLanguages.ts @@ -6,9 +6,9 @@ * 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 = { name: string; @@ -17,7 +17,7 @@ export type ISOLanguage = { }; // full list: https://github.com/meikidd/iso-639-1/blob/master/src/data.js -export const ISOLanguages: Record = { +export const ISOLanguages: { [languageCode in I18nResourceCode]: ISOLanguage } & Record = { // ############################# // ### ### // ### START: manually added ###