Skip to content

Commit 9ee2112

Browse files
committed
reusable getLocale
1 parent 1ef13af commit 9ee2112

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/i18n.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const messages = {
66
'zh-CN': zhCN,
77
}
88

9-
function getLocale() {
9+
export function getLocale(messages: { [key: string]: any }) {
1010
for (const language of navigator.languages) {
1111
if (language in messages) {
1212
return language
@@ -21,7 +21,7 @@ function getLocale() {
2121
}
2222

2323
const i18n = createI18n({
24-
locale: getLocale(),
24+
locale: getLocale(messages),
2525
messages,
2626
})
2727

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export { default as AdvancedConfig } from './AdvancedConfig.vue'
22
export { default as GearButton } from './GearButton.vue'
33
export { default as GlobalConfig } from './GlobalConfig.vue'
4+
export { getLocale } from './i18n'
45
export { default as InputMethodConfig } from './InputMethodConfig.vue'
56
export { default as PluginManager } from './PluginManager.vue'
67
export { default as ThemeConfig } from './ThemeConfig.vue'

0 commit comments

Comments
 (0)