Skip to content

Commit

Permalink
lang with navigator.language
Browse files Browse the repository at this point in the history
  • Loading branch information
swuecho committed Nov 26, 2023
1 parent b6c0148 commit 47d04d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions web/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import zhCN from './zh-CN.json'
import zhTW from './zh-TW.json'
import type { Language } from '@/store/modules/app/helper'

const defaultLocale = navigator.language.split('-')[0]

const i18n = createI18n({
locale: defaultLocale,
locale: navigator.language.split('-')[0],
fallbackLocale: 'en',
allowComposition: true,
messages: {
Expand Down
4 changes: 3 additions & 1 deletion web/src/store/modules/app/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export interface AppState {
language: Language
}

const defaultLanguage = navigator.language as Language

export function defaultSetting(): AppState {
return { siderCollapsed: false, theme: 'light', language: 'zh-CN' }
return { siderCollapsed: false, theme: 'light', language: defaultLanguage }
}

export function getLocalSetting(): AppState {
Expand Down

0 comments on commit 47d04d0

Please sign in to comment.