feat: multi-language(part.1)

This commit is contained in:
reco_luan 2020-03-23 18:58:44 +08:00
parent 7fc9eaa42a
commit d2bb87bdb1
7 changed files with 52 additions and 3 deletions

View File

@ -49,7 +49,7 @@
</div>
<div class="info-wrapper">
<PersonalInfo/>
<h4><i class="iconfont reco-category"></i> 分类</h4>
<h4><i class="iconfont reco-category"></i> {{homeBlogCfg.category}}</h4>
<ul class="category-wrapper">
<li class="category-item" v-for="(item, index) in this.$categories.list" :key="index">
<router-link :to="item.path">
@ -59,9 +59,9 @@
</li>
</ul>
<hr>
<h4 v-if="$tags.list.length !== 0"><i class="iconfont reco-tag"></i> 标签</h4>
<h4 v-if="$tags.list.length !== 0"><i class="iconfont reco-tag"></i> {{homeBlogCfg.tag}}</h4>
<TagList @getCurrentTag="getPagesByTags" />
<h4 v-if="$themeConfig.friendLink && $themeConfig.friendLink.length !== 0"><i class="iconfont reco-friend"></i> 友链</h4>
<h4 v-if="$themeConfig.friendLink && $themeConfig.friendLink.length !== 0"><i class="iconfont reco-friend"></i> {{homeBlogCfg.friendLink}}</h4>
<FriendLink />
</div>
</div>
@ -94,6 +94,9 @@ export default {
}
},
computed: {
homeBlogCfg () {
return this.$recoLocals.homeBlog
},
actionLink () {
const {
actionLink: link,
@ -130,6 +133,7 @@ export default {
mounted () {
this.recoShow = true
this._setPage(this._getStoragePage())
console.log(this)
},
methods: {
//

View File

@ -1,7 +1,9 @@
import postMixin from '@theme/mixins/posts'
import localMixin from '@theme/mixins/locals'
export default ({
Vue
}) => {
Vue.mixin(postMixin)
Vue.mixin(localMixin)
}

8
locals/en.js Normal file
View File

@ -0,0 +1,8 @@
export default {
homeBlog: {
article: 'article',
tag: 'tag',
category: 'category',
friendLink: 'friend link'
}
}

4
locals/index.js Normal file
View File

@ -0,0 +1,4 @@
import zhHans from './zh-hans.js'
import zhHant from './zh-hant.js'
import en from './en.js'
export { zhHans, zhHant, en }

8
locals/zh-hans.js Normal file
View File

@ -0,0 +1,8 @@
export default {
homeBlog: {
article: '文章',
tag: '标签',
category: '分类',
friendLink: '友情链接'
}
}

8
locals/zh-hant.js Normal file
View File

@ -0,0 +1,8 @@
export default {
homeBlog: {
article: '文章',
tag: '標簽',
category: '分類',
friendLink: '友情鏈接'
}
}

15
mixins/locals.js Normal file
View File

@ -0,0 +1,15 @@
import { zhHans, zhHant, en } from '../locals/index'
export default {
computed: {
$recoLocals () {
if (/^zh\-(CN|SG)$/.test(this.$lang)) {
return zhHans
}
if (/^zh\-(HK|MO|TW)$/.test(this.$lang)) {
return zhHant
}
return en
}
}
}