Skip to content

Commit 47ea5c7

Browse files
Translation (english + 中文) of the litemall-admin interface (#541)
* Add: i18n translations with vue-i18n (english + 中文) * Add: LocaleChanger component on admin login page
1 parent 449aae9 commit 47ea5c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3033
-949
lines changed

litemall-admin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"v-charts": "1.19.0",
6262
"vue": "2.6.10",
6363
"vue-count-to": "1.0.13",
64+
"vue-i18n": "^8.28.2",
6465
"vue-router": "3.0.2",
6566
"vuex": "3.1.0",
6667
"xlsx": ">=0.17.0"

litemall-admin/src/components/BackToTop/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<transition :name="transitionName">
33
<div v-show="visible" :style="customStyle" class="back-to-ceiling" @click="backToTop">
44
<svg width="16" height="16" viewBox="0 0 17 17" xmlns="http://www.w3.org/2000/svg" class="Icon Icon--backToTopArrow" aria-hidden="true" style="height: 16px; width: 16px;">
5-
<title>回到顶部</title>
5+
<title>{{ $t('app.button.back_to_top') }}</title>
66
<g>
77
<path d="M12.036 15.59c0 .55-.453.995-.997.995H5.032c-.55 0-.997-.445-.997-.996V8.584H1.03c-1.1 0-1.36-.633-.578-1.416L7.33.29c.39-.39 1.026-.385 1.412 0l6.878 6.88c.782.78.523 1.415-.58 1.415h-3.004v7.004z" fill-rule="evenodd"/>
88
</g>

litemall-admin/src/components/Breadcrumb/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<el-breadcrumb class="app-breadcrumb" separator="/">
33
<transition-group name="breadcrumb">
44
<el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
5-
<span v-if="item.redirect === 'noredirect' || index == levelList.length - 1" class="no-redirect">{{ item.meta.title }}</span>
6-
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
5+
<span v-if="item.redirect === 'noredirect' || index == levelList.length - 1" class="no-redirect">{{ $t(item.meta.title) }}</span>
6+
<a v-else @click.prevent="handleLink(item)">{{ $t(item.meta.title) }}</a>
77
</el-breadcrumb-item>
88
</transition-group>
99
</el-breadcrumb>
@@ -38,7 +38,7 @@ export default {
3838
)
3939
const first = matched[0]
4040
if (!this.isDashboard(first)) {
41-
matched = [{ path: '/dashboard', meta: { title: '首页' }}].concat(matched)
41+
matched = [{ path: '/dashboard', meta: { title: 'app.menu.dashboard' }}].concat(matched)
4242
}
4343
this.levelList = matched.filter(
4444
item => item.meta && item.meta.title && item.meta.breadcrumb !== false
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- https://kazupon.github.io/vue-i18n/guide/locale.html -->
2+
<template>
3+
<el-select v-model="$i18n.locale" size="mini" placeholder="lang" class="select">
4+
<el-option v-for="(lang, i) in langs" :key="`Lang${i}`" :label="lang.label" :value="lang.value" />
5+
</el-select>
6+
</template>
7+
8+
<script>
9+
export default {
10+
name: 'LocaleChanger',
11+
data() {
12+
return {
13+
langs: Object.entries(this.$i18n.messages)
14+
.map(([key, messages]) => ({
15+
label: messages.lang ?? key,
16+
value: key
17+
}))
18+
}
19+
}
20+
}
21+
</script>
22+
23+
<style>
24+
.select {
25+
width: 180px;
26+
}
27+
</style>

0 commit comments

Comments
 (0)