+
+
Option:
+
+
setVisibleAvatar(e.target.checked)}
>
-
+
-
+
{text}
),
diff --git a/web/src/constants/common.ts b/web/src/constants/common.ts
index 9b442556f..425715f3a 100644
--- a/web/src/constants/common.ts
+++ b/web/src/constants/common.ts
@@ -61,6 +61,28 @@ export const LanguageMap = {
'Portuguese BR': 'Português BR',
};
+export enum LanguageAbbreviation {
+ En = 'en',
+ Zh = 'zh',
+ ZhTraditional = 'zh-TRADITIONAL',
+ Id = 'id',
+ Ja = 'ja',
+ Es = 'es',
+ Vi = 'vi',
+ PtBr = 'pt-BR',
+}
+
+export const LanguageAbbreviationMap = {
+ [LanguageAbbreviation.En]: 'English',
+ [LanguageAbbreviation.Zh]: '简体中文',
+ [LanguageAbbreviation.ZhTraditional]: '繁體中文',
+ [LanguageAbbreviation.Id]: 'Indonesia',
+ [LanguageAbbreviation.Es]: 'Español',
+ [LanguageAbbreviation.Vi]: 'Tiếng việt',
+ [LanguageAbbreviation.Ja]: '日本語',
+ [LanguageAbbreviation.PtBr]: 'Português BR',
+};
+
export const LanguageTranslationMap = {
English: 'en',
Chinese: 'zh',
diff --git a/web/src/locales/config.ts b/web/src/locales/config.ts
index f0047e4ab..8c4e56e30 100644
--- a/web/src/locales/config.ts
+++ b/web/src/locales/config.ts
@@ -2,6 +2,7 @@ import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';
+import { LanguageAbbreviation } from '@/constants/common';
import translation_en from './en';
import translation_es from './es';
import translation_id from './id';
@@ -13,14 +14,14 @@ import translation_zh from './zh';
import translation_zh_traditional from './zh-traditional';
const resources = {
- en: translation_en,
- zh: translation_zh,
- 'zh-TRADITIONAL': translation_zh_traditional,
- id: translation_id,
- ja: translation_ja,
- es: translation_es,
- vi: translation_vi,
- 'pt-BR': translation_pt_br,
+ [LanguageAbbreviation.En]: translation_en,
+ [LanguageAbbreviation.Zh]: translation_zh,
+ [LanguageAbbreviation.ZhTraditional]: translation_zh_traditional,
+ [LanguageAbbreviation.Id]: translation_id,
+ [LanguageAbbreviation.Ja]: translation_ja,
+ [LanguageAbbreviation.Es]: translation_es,
+ [LanguageAbbreviation.Vi]: translation_vi,
+ [LanguageAbbreviation.PtBr]: translation_pt_br,
};
const enFlattened = flattenObject(translation_en);
const viFlattened = flattenObject(translation_vi);
@@ -48,16 +49,7 @@ i18n
detection: {
lookupLocalStorage: 'lng',
},
- supportedLngs: [
- 'en',
- 'zh',
- 'zh-TRADITIONAL',
- 'id',
- 'es',
- 'vi',
- 'ja',
- 'pt-BR',
- ],
+ supportedLngs: Object.values(LanguageAbbreviation),
resources,
fallbackLng: 'en',
interpolation: {
@@ -65,15 +57,4 @@ i18n
},
});
-export const languageOptions = [
- { value: 'en', label: 'English' },
- { value: 'zh', label: 'Chinese' },
- { value: 'zh-TRADITIONAL', label: 'Traditional Chinese' },
- { value: 'id', label: 'Indonesian' },
- { value: 'es', label: 'Spanish' },
- { value: 'vi', label: 'Vietnamese' },
- { value: 'ja', label: 'Japanese' },
- { value: 'pt-BR', label: 'Brazilian Portuguese' },
-];
-
export default i18n;