Skip to content

Commit d2bb87b

Browse files
author
reco_luan
committed
feat: multi-language(part.1)
1 parent 7fc9eaa commit d2bb87b

File tree

7 files changed

+52
-3
lines changed

7 files changed

+52
-3
lines changed

components/HomeBlog.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
</div>
5050
<div class="info-wrapper">
5151
<PersonalInfo/>
52-
<h4><i class="iconfont reco-category"></i> 分类</h4>
52+
<h4><i class="iconfont reco-category"></i> {{homeBlogCfg.category}}</h4>
5353
<ul class="category-wrapper">
5454
<li class="category-item" v-for="(item, index) in this.$categories.list" :key="index">
5555
<router-link :to="item.path">
@@ -59,9 +59,9 @@
5959
</li>
6060
</ul>
6161
<hr>
62-
<h4 v-if="$tags.list.length !== 0"><i class="iconfont reco-tag"></i> 标签</h4>
62+
<h4 v-if="$tags.list.length !== 0"><i class="iconfont reco-tag"></i> {{homeBlogCfg.tag}}</h4>
6363
<TagList @getCurrentTag="getPagesByTags" />
64-
<h4 v-if="$themeConfig.friendLink && $themeConfig.friendLink.length !== 0"><i class="iconfont reco-friend"></i> 友链</h4>
64+
<h4 v-if="$themeConfig.friendLink && $themeConfig.friendLink.length !== 0"><i class="iconfont reco-friend"></i> {{homeBlogCfg.friendLink}}</h4>
6565
<FriendLink />
6666
</div>
6767
</div>
@@ -94,6 +94,9 @@ export default {
9494
}
9595
},
9696
computed: {
97+
homeBlogCfg () {
98+
return this.$recoLocals.homeBlog
99+
},
97100
actionLink () {
98101
const {
99102
actionLink: link,
@@ -130,6 +133,7 @@ export default {
130133
mounted () {
131134
this.recoShow = true
132135
this._setPage(this._getStoragePage())
136+
console.log(this)
133137
},
134138
methods: {
135139
// 获取当前页码

enhanceApp.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import postMixin from '@theme/mixins/posts'
2+
import localMixin from '@theme/mixins/locals'
23

34
export default ({
45
Vue
56
}) => {
67
Vue.mixin(postMixin)
8+
Vue.mixin(localMixin)
79
}

locals/en.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
homeBlog: {
3+
article: 'article',
4+
tag: 'tag',
5+
category: 'category',
6+
friendLink: 'friend link'
7+
}
8+
}

locals/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import zhHans from './zh-hans.js'
2+
import zhHant from './zh-hant.js'
3+
import en from './en.js'
4+
export { zhHans, zhHant, en }

locals/zh-hans.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
homeBlog: {
3+
article: '文章',
4+
tag: '标签',
5+
category: '分类',
6+
friendLink: '友情链接'
7+
}
8+
}

locals/zh-hant.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
homeBlog: {
3+
article: '文章',
4+
tag: '標簽',
5+
category: '分類',
6+
friendLink: '友情鏈接'
7+
}
8+
}

mixins/locals.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { zhHans, zhHant, en } from '../locals/index'
2+
3+
export default {
4+
computed: {
5+
$recoLocals () {
6+
if (/^zh\-(CN|SG)$/.test(this.$lang)) {
7+
return zhHans
8+
}
9+
if (/^zh\-(HK|MO|TW)$/.test(this.$lang)) {
10+
return zhHant
11+
}
12+
return en
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)