mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 08:56:47 +08:00
### What problem does this PR solve? Feat: Add LanguageAbbreviation to simplify language resource files. #5065 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user