diff --git a/src/i18n.js b/src/i18n.js
index d80c7ed..b007020 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -7,13 +7,17 @@ Vue.use(VueI18n)
function loadLocaleMessages () {
const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i)
const messages = {}
- locales.keys().forEach(key => {
+ for (const key of locales.keys()) {
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
if (matched && matched.length > 1) {
const locale = matched[1]
- messages[locale] = locales(key)
+ const localeElementUI = require(`element-ui/lib/locale/lang/${locales(key)._element}`)
+ messages[locale] = {
+ ...locales(key),
+ ...localeElementUI ? localeElementUI.default : {}
+ }
}
- })
+ }
return messages
}
@@ -24,8 +28,10 @@ Vue.prototype.$languages = Object.keys(messages).map(langlage => ({
value: langlage
}))
-export default new VueI18n({
+const i18n = new VueI18n({
locale: util.cookies.get('lang') || process.env.VUE_APP_I18N_LOCALE,
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE,
messages
})
+
+export default i18n
diff --git a/src/layout/header-aside/components/header-locales/index.vue b/src/layout/header-aside/components/header-locales/index.vue
index f2ebf02..d59f18a 100644
--- a/src/layout/header-aside/components/header-locales/index.vue
+++ b/src/layout/header-aside/components/header-locales/index.vue
@@ -19,24 +19,10 @@
diff --git a/src/locales/en.json b/src/locales/en.json
index 63a33df..de5e8f3 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -1,3 +1,13 @@
{
- "_name": "English"
+ "_element": "en",
+ "_name": "English",
+ "page": {
+ "demo": {
+ "playground": {
+ "locales": {
+ "text": "D2Admin is a fully open source and free enterprise back-end product front-end integration solution, using the latest front-end technology stack, has prepared most of the project preparations, and with a lot of sample code to help the management system agile development."
+ }
+ }
+ }
+ }
}
diff --git a/src/locales/ja.json b/src/locales/ja.json
index 5f74259..d11fcd7 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -1,3 +1,13 @@
{
- "_name": "日本語"
+ "_element": "ja",
+ "_name": "日本語",
+ "page": {
+ "demo": {
+ "playground": {
+ "locales": {
+ "text": "D2Adminは、最新のフロントエンドテクノロジースタックを使用した、完全にオープンソースの無料エンタープライズバックエンド製品フロントエンド統合ソリューションであり、プロジェクトのほとんどの準備を整えており、システムのアジャイル開発の管理に役立つ多くのサンプルコードを備えています。"
+ }
+ }
+ }
+ }
}
diff --git a/src/locales/mixin.js b/src/locales/mixin.js
new file mode 100644
index 0000000..deed850
--- /dev/null
+++ b/src/locales/mixin.js
@@ -0,0 +1,20 @@
+export default {
+ methods: {
+ onChangeLocale (command) {
+ this.$i18n.locale = command
+ let message = `当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`
+ if (['TRAVIS', 'NETLIFY'].includes(process.env.VUE_APP_BUILD_MODE)) {
+ message = [
+ `当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`,
+ `仅提供切换功能,没有配置具体的语言数据 `,
+ `文档参考:《国际化 | D2Admin》`
+ ].join('
')
+ }
+ this.$notify({
+ title: '语言变更',
+ dangerouslyUseHTMLString: true,
+ message
+ })
+ }
+ }
+}
diff --git a/src/locales/zh-chs.json b/src/locales/zh-chs.json
index a272cee..8fc31fe 100644
--- a/src/locales/zh-chs.json
+++ b/src/locales/zh-chs.json
@@ -1,3 +1,13 @@
{
- "_name": "简体中文"
+ "_element": "zh-CN",
+ "_name": "简体中文",
+ "page": {
+ "demo": {
+ "playground": {
+ "locales": {
+ "text": "D2Admin 是一个完全 开源免费 的企业中后台产品前端集成方案,使用最新的前端技术栈,已经做好大部分项目前期准备工作,并且带有大量示例代码,助力管理系统敏捷开发。"
+ }
+ }
+ }
+ }
}
diff --git a/src/locales/zh-cht.json b/src/locales/zh-cht.json
index ee7f22a..ee51ba7 100644
--- a/src/locales/zh-cht.json
+++ b/src/locales/zh-cht.json
@@ -1,3 +1,13 @@
{
- "_name": "繁體中文"
+ "_element": "zh-TW",
+ "_name": "繁體中文",
+ "page": {
+ "demo": {
+ "playground": {
+ "locales": {
+ "text": "D2Admin 是一個完全 開源免費 的企業中後台產品前端集成方案,使用最新的前端技術棧,已經做好大部分項目前期準備工作,並且帶有大量示例代碼,助力管理系統敏捷開發。"
+ }
+ }
+ }
+ }
}
diff --git a/src/plugin/d2admin/index.js b/src/plugin/d2admin/index.js
index 24b46ca..7c739e9 100644
--- a/src/plugin/d2admin/index.js
+++ b/src/plugin/d2admin/index.js
@@ -7,6 +7,8 @@ import 'flex.css'
import '@/components'
// svg 图标
import '@/assets/svg-icons'
+// 国际化
+import i18n from '@/i18n.js'
// 功能插件
import pluginError from '@/plugin/error'
@@ -27,7 +29,9 @@ export default {
// 构建时间
Vue.prototype.$buildTime = process.env.VUE_APP_BUILD_TIME
// Element
- Vue.use(ElementUI)
+ Vue.use(ElementUI, {
+ i18n: (key, value) => i18n.t(key, value)
+ })
// 插件
Vue.use(pluginError)
Vue.use(pluginLog)
diff --git a/src/store/modules/d2admin/modules/account.js b/src/store/modules/d2admin/modules/account.js
index b8a4d42..18ea5ff 100644
--- a/src/store/modules/d2admin/modules/account.js
+++ b/src/store/modules/d2admin/modules/account.js
@@ -70,8 +70,6 @@ export default {
if (confirm) {
commit('d2admin/gray/set', true, { root: true })
MessageBox.confirm('确定要注销当前用户吗', '注销用户', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
diff --git a/src/views/system/login/page.vue b/src/views/system/login/page.vue
index 993e803..1233019 100644
--- a/src/views/system/login/page.vue
+++ b/src/views/system/login/page.vue
@@ -85,8 +85,7 @@
+ @click="onChangeLocale(language.value)">
{{ language.label }}