Skip to content

Commit

Permalink
fix: 🐛 gbeata component locale static refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
G committed Sep 12, 2024
1 parent a8292e3 commit d4209bd
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions packages/gbeata/src/locale/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import { AnyKeyProps } from '../types/AnyKeyProps'
import zhCN from './zh_CN'
import enUS from './en_US'
import jaJP from './ja_JP'
import koKr from './ko_KR'
import { AnyKeyProps } from '../types/AnyKeyProps';
import enUS from './en_US';
import jaJP from './ja_JP';
import koKr from './ko_KR';
import zhCN from './zh_CN';

export let activeLang = localStorage.getItem('MULTIWAY_LOCALE') || 'zh_CN'
export let activeLang = localStorage.getItem('MULTIWAY_LOCALE') || 'zh_CN';
// activeLang = JSON.parse(activeLang);

let langMap: AnyKeyProps = {
zh_CN: zhCN,
en_US: enUS,
ja_JP: jaJP,
ko_KR: koKr
}
ko_KR: koKr,
};

export const isJP = () => {
return activeLang === 'ja_JP'
}
return activeLang === 'ja_JP';
};

/** 设置语言 */
export const setLanguage = (lang: string) => {
activeLang = lang
localStorage.setItem('MULTIWAY_LOCALE', lang)
}
activeLang = lang;
localStorage.setItem('MULTIWAY_LOCALE', lang);
};

export default langMap[activeLang]
const handler: any = {
get(target: any, prop: any) {
return target?.[activeLang]
? target?.[activeLang]?.[prop]
: target?.[JSON.parse(activeLang)]?.[prop] || '-';
},
};

export default new Proxy(langMap, handler);

0 comments on commit d4209bd

Please sign in to comment.