feat: build framework
This commit is contained in:
7
locales/en.ts
Normal file
7
locales/en.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// en.ts
|
||||
export default {
|
||||
login: {
|
||||
username: 'Username',
|
||||
password: 'Password'
|
||||
}
|
||||
}
|
||||
17
locales/index.ts
Normal file
17
locales/index.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// index.ts
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import zh from './zh'
|
||||
import en from './en'
|
||||
|
||||
const messages = {
|
||||
en,
|
||||
zh
|
||||
}
|
||||
const language = (navigator.language || 'en').toLocaleLowerCase() // 这是获取浏览器的语言
|
||||
const i18n = createI18n({
|
||||
locale: localStorage.getItem('lang') || language.split('-')[0] || 'en', // 首先从缓存里拿,没有的话就用浏览器语言,
|
||||
fallbackLocale: 'en', // 设置备用语言
|
||||
messages
|
||||
})
|
||||
|
||||
export default i18n
|
||||
7
locales/zh.ts
Normal file
7
locales/zh.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// zh.ts
|
||||
export default {
|
||||
login: {
|
||||
username: '账号',
|
||||
password: '密码'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user