feat: Adding an Internationalization Instance

pull/921/head
冯建军 3 years ago
parent dc1926a8d4
commit 000b7f4a54

@ -32,7 +32,7 @@
<el-dropdown-item>Dashboard</el-dropdown-item> <el-dropdown-item>Dashboard</el-dropdown-item>
</router-link> </router-link>
<el-dropdown-item divided> <el-dropdown-item divided>
<span style="display:block;" @click="logout">Log Out</span> <span style="display:block;" @click="logout">{{ $t('system.logOut') }}</span>
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>

@ -5,8 +5,10 @@ import elEn from 'element-ui/lib/locale/lang/en'
import zh from './lang/zh' import zh from './lang/zh'
import en from './lang/en' import en from './lang/en'
const lang = localStorage.getItem('locale_lang')
export const i18nConfig = { export const i18nConfig = {
locale: 'en', // 默认语种 locale: lang || 'en', // 默认语种
messages: { messages: {
zh: { ...zh, ...elZh }, // 中文包 zh: { ...zh, ...elZh }, // 中文包
en: { ...en, ...elEn } // 英文包 en: { ...en, ...elEn } // 英文包

@ -1,3 +1,31 @@
export default { export default {
// 系统
system: {
login: 'Login Form',
username: 'Username',
password: 'Password',
logOut: 'Log Out'
},
// 公共
common: {
search: 'Search',
addition: 'Addition',
serialNumber: 'Serial Number',
operation: 'Operation',
edit: 'Edit',
delete: 'Delete',
cancel: 'Cancel',
confirm: 'Confirm'
},
// 线程池
threadPool: {
tenant: 'Tenant',
project: 'Project',
threadPool: 'Thread Pool',
}
} }

@ -1,3 +1,28 @@
export default { export default {
// 系统
system: {
login: '登 陆',
username: '用户名',
password: '密码',
logOut: '注销'
},
// 公共
common: {
search: '搜索',
addition: '添加',
serialNumber: '序号',
operation: '操作',
edit: '编辑',
delete: '删除',
cancel: '取消',
confirm: '确认'
},
// 线程池
threadPool: {
tenant: '租户',
project: '项目',
threadPool: '线程池',
}
} }

@ -26,6 +26,10 @@ export default {
currentLang: '' currentLang: ''
} }
}, },
mounted() {
const lang = this.$i18n.locale
this.currentLang = lang || null
},
computed: { computed: {
currentLangName() { currentLangName() {
const langItem = this.langSelectList.find(item => item.lang === this.currentLang) const langItem = this.langSelectList.find(item => item.lang === this.currentLang)
@ -36,6 +40,8 @@ export default {
// //
selectedLang(value) { selectedLang(value) {
this.currentLang = value this.currentLang = value
this.$i18n.locale = value
localStorage.setItem('locale_lang', value)
} }
} }
} }
@ -44,10 +50,13 @@ export default {
.lang-drop-wrap{ .lang-drop-wrap{
height: 100%; height: 100%;
margin-right: 15px; margin-right: 15px;
.el-dropdown-link{
cursor: pointer;
}
}
.dropdown-item-text{ .dropdown-item-text{
&[data-active=true] { &[data-active=true] {
color: var(--jjext-color-dropdown-text) !important; color: var(--jjext-color-dropdown-text) !important;
} }
} }
}
</style> </style>

@ -3,7 +3,7 @@
<div class="filter-container"> <div class="filter-container">
<el-select <el-select
v-model="listQuery.tenantId" v-model="listQuery.tenantId"
placeholder="租户" :placeholder="$t('threadPool.tenant')"
style="width: 220px" style="width: 220px"
filterable filterable
class="filter-item" class="filter-item"
@ -18,7 +18,7 @@
</el-select> </el-select>
<el-select <el-select
v-model="listQuery.itemId" v-model="listQuery.itemId"
placeholder="项目" :placeholder="$t('threadPool.project')"
style="width: 220px" style="width: 220px"
filterable filterable
class="filter-item" class="filter-item"
@ -33,7 +33,7 @@
</el-select> </el-select>
<el-select <el-select
v-model="listQuery.tpId" v-model="listQuery.tpId"
placeholder="线程池" :placeholder="$t('threadPool.threadPool')"
style="width: 220px" style="width: 220px"
filterable filterable
class="filter-item" class="filter-item"
@ -53,7 +53,7 @@
icon="el-icon-search" icon="el-icon-search"
@click="fetchData" @click="fetchData"
> >
搜索 {{ $t('common.search') }}
</el-button> </el-button>
<el-button <el-button
class="filter-item" class="filter-item"
@ -63,7 +63,7 @@
@click="handleCreate" @click="handleCreate"
:disabled="isEditDisabled" :disabled="isEditDisabled"
> >
添加 {{ $t('common.addition') }}
</el-button> </el-button>
</div> </div>
<el-table <el-table
@ -74,7 +74,7 @@
fit fit
highlight-current-row highlight-current-row
> >
<el-table-column fixed label="序号" width="80"> <el-table-column fixed :label="$t('common.serialNumber')" width="80">
<template slot-scope="scope">{{ scope.$index + 1 }}</template> <template slot-scope="scope">{{ scope.$index + 1 }}</template>
</el-table-column> </el-table-column>
<el-table-column label="租户" width="150"> <el-table-column label="租户" width="150">
@ -129,16 +129,16 @@
<template slot-scope="scope">{{ scope.row.gmtModified }}</template> <template slot-scope="scope">{{ scope.row.gmtModified }}</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="操作" :label="$t('common.operation')"
fixed="right" fixed="right"
width="90" width="90"
align="center" align="center"
class-name="small-padding fixed-width" class-name="small-padding fixed-width"
> >
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-button type="text" size="small" @click="handleUpdate(row)"> </el-button> <el-button type="text" size="small" @click="handleUpdate(row)"> {{ $t('common.edit') }} </el-button>
<el-button size="small" :disabled="isEditDisabled" type="text" @click="handleDelete(row)"> <el-button size="small" :disabled="isEditDisabled" type="text" @click="handleDelete(row)">
删除 {{ $t('common.delete') }}
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -327,9 +327,9 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> 取消 </el-button> <el-button @click="dialogFormVisible = false"> {{ $t('common.cancel') }} </el-button>
<el-button type="primary" @click="dialogStatus === 'create' ? createData() : updateData()"> <el-button type="primary" @click="dialogStatus === 'create' ? createData() : updateData()">
确认 {{ $t('common.confirm') }}
</el-button> </el-button>
</div> </div>
</el-dialog> </el-dialog>

@ -9,7 +9,7 @@
label-position="left" label-position="left"
> >
<div class="title-container"> <div class="title-container">
<h3 class="title">Login Form</h3> <h3 class="title">{{ $t('system.login') }}</h3>
</div> </div>
<el-form-item prop="username"> <el-form-item prop="username">
@ -19,7 +19,7 @@
<el-input <el-input
ref="username" ref="username"
v-model="loginForm.username" v-model="loginForm.username"
placeholder="Username" :placeholder="$t('system.username')"
name="username" name="username"
type="text" type="text"
tabindex="1" tabindex="1"
@ -37,7 +37,7 @@
ref="password" ref="password"
v-model="loginForm.password" v-model="loginForm.password"
:type="passwordType" :type="passwordType"
placeholder="Password" :placeholder="$t('system.password')"
name="password" name="password"
tabindex="2" tabindex="2"
autocomplete="on" autocomplete="on"

Loading…
Cancel
Save