Skip to content

Commit

Permalink
Improve i18n resource typing
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed Apr 24, 2024
1 parent a7cafb5 commit 082f923
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/util/isoLanguages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<ISOLanguageCode, ISOLanguage> = {
export const ISOLanguages: { [languageCode in I18nResourceCode]: ISOLanguage } & Record<string, ISOLanguage> = {
// #############################
// ### ###
// ### START: manually added ###
Expand Down

0 comments on commit 082f923

Please sign in to comment.