-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import vue-i18n & Translate the Apps page
- Loading branch information
1 parent
1fc2fce
commit a22d2c9
Showing
9 changed files
with
146 additions
and
19 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"apps": { | ||
"tabs": { | ||
"AppStore": "App Store", | ||
"Messages": "Messages", | ||
"Photos": "Photos" | ||
}, | ||
"appList": { | ||
"TV": "TV", | ||
"Music": "Music", | ||
"Mindfulness": "Mindfulness", | ||
"Settings": "Settings", | ||
"Freeform": "Freeform", | ||
"Safari": "Safari", | ||
"Photos": "Photos", | ||
"Notes": "Notes", | ||
"AppStore": "App Store", | ||
"Mail": "Mail", | ||
"Messages": "Messages", | ||
"Keynote": "Keynote", | ||
"CompatibleApps": "Compatible Apps" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// https://vue-i18n.intlify.dev/ | ||
import { createI18n } from 'vue-i18n' | ||
import en from './en.json' | ||
import zh from './zh.json' | ||
|
||
const messages = { | ||
en, | ||
zh | ||
} | ||
|
||
// 获取语言 | ||
export function getLanguage() { | ||
// 获取浏览器语言 | ||
const language = navigator.language.toLowerCase() | ||
// 获取 messages 的所有 key | ||
const locales = Object.keys(messages) | ||
// 遍历所有 key,判断是否包含当前语言 | ||
for (const locale of locales) { | ||
if (language.indexOf(locale) > -1) { | ||
return locale | ||
} | ||
} | ||
return 'en' | ||
} | ||
|
||
// 创建i18n实例 | ||
const i18n = createI18n({ | ||
legacy: false, | ||
locale: getLanguage(), | ||
fallbackLocale: 'en', | ||
messages: messages | ||
}) | ||
|
||
export default i18n |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"apps": { | ||
"tabs": { | ||
"AppStore": "App Store", | ||
"Messages": "信息", | ||
"Photos": "照片" | ||
}, | ||
"appList": { | ||
"TV": "TV", | ||
"Music": "音乐", | ||
"Mindfulness": "正念", | ||
"Settings": "设置", | ||
"Freeform": "无边记", | ||
"Safari": "Safari浏览器", | ||
"Photos": "照片", | ||
"Notes": "备忘录", | ||
"AppStore": "App Store", | ||
"Mail": "邮件", | ||
"Messages": "信息", | ||
"Keynote": "Keynote", | ||
"CompatibleApps": "兼容App" | ||
} | ||
} | ||
} |
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,17 +1,19 @@ | ||
import './assets/style/main.scss' | ||
|
||
import { createApp } from 'vue' | ||
import { createPinia } from 'pinia' | ||
|
||
// 导入 MingCute 图标库 | ||
import 'mingcute_icon/font/Mingcute.css' | ||
|
||
import App from './App.vue' | ||
import router from './router' | ||
import pinia from './stores' | ||
import i18n from './i18n' | ||
|
||
const app = createApp(App) | ||
|
||
app.use(createPinia()) | ||
app.use(router) | ||
app.use(pinia) | ||
app.use(i18n) | ||
|
||
app.mount('#app') |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// https://pinia.vuejs.org/ | ||
import { createPinia } from 'pinia' | ||
|
||
export default createPinia() |
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
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