File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
app-engine/frontend/src/locale Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,27 @@ import i18n from 'i18next';
77import { initReactI18next } from "react-i18next" ;
88import en from './en_US.json' ;
99import zh from './zh_CN.json' ;
10+ import coreEn from '@fit-elsa/elsa-core/locales/en.json' ;
11+ import coreZh from '@fit-elsa/elsa-core/locales/zh.json' ;
12+ import reactEn from '@fit-elsa/elsa-react/locales/en.json' ;
13+ import reactZh from '@fit-elsa/elsa-react/locales/zh.json' ;
14+
15+ const mergeTranslations = ( ...translationObjects ) => {
16+ // 从右向左合并(右侧优先级更高)
17+ return translationObjects
18+ . filter ( obj => obj ) // 过滤掉假值(undefined/null
19+ . reduce ( ( merged , current ) => ( { ...merged , ...current } ) , { } ) ;
20+ } ;
1021
1122const resources = {
1223 en : {
13- translation : en
24+ translation : mergeTranslations ( coreEn , reactEn , en ) // 优先级顺序: en > reactEn > coreEn
1425 } ,
1526 zh : {
16- translation : zh
27+ translation : mergeTranslations ( coreZh , reactZh , zh ) // 优先级顺序: zh > reactZh > coreZh
1728 }
1829} ;
30+
1931const getCookie = ( cname ) => {
2032 const name = `${ cname } =` ;
2133 const ca = document . cookie . split ( ';' ) ;
You can’t perform that action at this time.
0 commit comments