Skip to content

Commit 0269874

Browse files
author
reco_luan
committed
feat(vuepress-plugin-comments): add internationalization default config
add internationalization default config for valine
1 parent 657f8ce commit 0269874

File tree

1 file changed

+17
-0
lines changed
  • packages/@vuepress-reco/vuepress-plugin-comments/bin

1 file changed

+17
-0
lines changed

packages/@vuepress-reco/vuepress-plugin-comments/bin/Valine.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,28 @@ export default {
1616
}
1717
}
1818
},
19+
computed: {
20+
lang () {
21+
const { $lang } = this
22+
if (/^zh\-(CN|SG)$/.test($lang)) {
23+
return 'zh-CN'
24+
}
25+
if (/^zh\-(HK|MO|TW)$/.test($lang)) {
26+
return 'zh-TW'
27+
}
28+
if (/^ja\-JP$/.test($lang)) {
29+
return 'ja'
30+
}
31+
return 'en'
32+
}
33+
},
1934
mounted: function () {
2035
this.initValine()
2136
},
2237
methods: {
2338
initValine () {
2439
const Valine = require('valine')
40+
const lang = this.lang
2541
const valineOptions = {
2642
el: '#valine',
2743
placeholder: 'just go go',
@@ -31,6 +47,7 @@ export default {
3147
visitor: true,
3248
recordIP: false,
3349
path: window.location.pathname,
50+
lang,
3451
...this.options
3552
}
3653

0 commit comments

Comments
 (0)