7 changed files with 112 additions and 7 deletions
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"login":{ |
||||
|
"title": "Bronze Age 2022", |
||||
|
"username_placeholder": "Username", |
||||
|
"password_placeholder": "Password", |
||||
|
"btnText": "Login" |
||||
|
}, |
||||
|
"home":"Bronze Age 2021", |
||||
|
"welcome":"Welcome To Home" |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"login":{ |
||||
|
"title": "青铜时代2022", |
||||
|
"username_placeholder": "用户名", |
||||
|
"password_placeholder": "密码", |
||||
|
"btnText": "登录" |
||||
|
}, |
||||
|
"home":"青铜时代2021", |
||||
|
"welcome":"欢迎来首页" |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
import LanguageDetector from "i18next-browser-languagedetector" |
||||
|
import i18n from "i18next" |
||||
|
import enUsTrans from "@/assets/locales/en-us.json" |
||||
|
import zhCnTrans from "@/assets/locales/zh-cn.json" |
||||
|
import { initReactI18next } from "react-i18next" |
||||
|
|
||||
|
i18n |
||||
|
.use(LanguageDetector) //嗅探当前浏览器语言
|
||||
|
.use(initReactI18next) //init i18next
|
||||
|
.init({ |
||||
|
//引入资源文件
|
||||
|
resources: { |
||||
|
en: { |
||||
|
translation: enUsTrans, |
||||
|
}, |
||||
|
zh: { |
||||
|
translation: zhCnTrans, |
||||
|
}, |
||||
|
}, |
||||
|
//选择默认语言,选择内容为上述配置中的key,即en/zh
|
||||
|
fallbackLng: "zh", |
||||
|
debug: false, |
||||
|
interpolation: { |
||||
|
escapeValue: false, // not needed for react as it escapes by default
|
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
export default i18n |
Loading…
Reference in new issue