forked from vuejs/docs
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathvuer-language.vue
70 lines (59 loc) · 1.33 KB
/
vuer-language.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<li :title="this.title" :class="{ highlighted }">{{ this.name }}</li>
</template>
<script>
import { getPreferredLanguageCode } from './utils'
const languageNameFor = {
en: 'English',
nl: 'Nederlands',
zh: '中文',
vi: 'Tiếng Việt',
pl: 'Polski',
pt: 'Português',
ru: 'Русский',
jp: '日本語',
fr: 'Français',
de: 'Deutsch',
el: 'Ελληνικά',
es: 'Español',
hi: 'हिंदी',
fa: 'فارسی',
ko: '한국어',
ro: 'Română',
uk: 'Українська',
no: 'Norwegian'
}
export default {
props: {
vuerName: String,
code: String
},
data: () => ({
preferredCode: 'en'
}),
mounted () {
// since getPreferredLanguageCode() depends on window.navigator, it should be placed inside mounted()
this.preferredCode = getPreferredLanguageCode().split('-')[0]
},
computed: {
isUserPreferredLanguage () {
return this.code === this.preferredCode
},
isEnglish () {
return this.code === 'en'
},
highlighted () {
return this.isUserPreferredLanguage && !this.isEnglish
},
title () {
if (this.highlighted) {
return `${this.vuerName} can give technical talks in your preferred language.`
}
return this.name
},
name () {
return languageNameFor[this.code]
}
}
}
</script>