-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 gbeata component locale static refresh
- Loading branch information
G
committed
Sep 12, 2024
1 parent
a8292e3
commit d4209bd
Showing
1 changed file
with
23 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |