Initial commit: 网络验证平台
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
import { useStorage } from '@vueuse/core'
|
||||
|
||||
export type Language = 'en' | 'zh'
|
||||
|
||||
export const SUPPORTED_LOCALES = new Set<Language>([
|
||||
'en',
|
||||
'zh',
|
||||
])
|
||||
|
||||
export const DEFAULT_LOCALE: Language = 'zh'
|
||||
|
||||
export const appLocale = useStorage<Language>('app-locale', DEFAULT_LOCALE)
|
||||
|
||||
watch(appLocale, (newLocale) => {
|
||||
if (!SUPPORTED_LOCALES.has(newLocale)) {
|
||||
appLocale.value = DEFAULT_LOCALE
|
||||
}
|
||||
}, { immediate: true })
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { App } from 'vue'
|
||||
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import type { Language } from '.'
|
||||
|
||||
import { appLocale, DEFAULT_LOCALE } from '.'
|
||||
import en from './en.json'
|
||||
import zh from './zh.json'
|
||||
|
||||
export function setupI18n(app: App) {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: appLocale.value,
|
||||
fallbackLocale: DEFAULT_LOCALE,
|
||||
messages: <Record<Language, Record<string, any>>>{
|
||||
zh,
|
||||
en,
|
||||
},
|
||||
})
|
||||
app.use(i18n)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user