-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLanguageSection.vue
More file actions
79 lines (65 loc) · 1.68 KB
/
LanguageSection.vue
File metadata and controls
79 lines (65 loc) · 1.68 KB
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
71
72
73
74
75
76
77
78
79
<template>
<section>
<div class="headerbar-label">
<label :for="inputId" class="language-label">{{ propertyReadable }}</label>
</div>
<template v-if="isEditable">
<Language :input-id="inputId"
:common-languages="commonLanguages"
:other-languages="otherLanguages"
:language.sync="language" />
</template>
<span v-else>
{{ t('nmcsettings', 'No language set') }}
</span>
</section>
</template>
<script>
import { loadState } from '@nextcloud/initial-state'
import Language from './Language.vue'
import { ACCOUNT_SETTING_PROPERTY_ENUM, ACCOUNT_SETTING_PROPERTY_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
const { languageMap: { activeLanguage, commonLanguages, otherLanguages } } = loadState('settings', 'personalInfoParameters', {})
export default {
name: 'LanguageSection',
components: {
Language,
},
data() {
return {
propertyReadable: ACCOUNT_SETTING_PROPERTY_READABLE_ENUM.LANGUAGE,
commonLanguages,
otherLanguages,
language: activeLanguage,
}
},
created() {
const localizeLanguage = (l) => {
if (l.code === 'de_DE') {
return { ...l, name: t('nmcsettings', 'Deutsch') }
}
if (l.code === 'en_GB') {
return { ...l, name: t('nmcsettings', 'English') }
}
return l
}
this.commonLanguages = this.commonLanguages.map(localizeLanguage)
this.otherLanguages = this.otherLanguages.map(localizeLanguage)
},
computed: {
inputId() {
return `account-setting-${ACCOUNT_SETTING_PROPERTY_ENUM.LANGUAGE}`
},
isEditable() {
return Boolean(this.language)
},
},
}
</script>
<style lang="scss" scoped>
section {
padding: 10px 10px;
&::v-deep button:disabled {
cursor: default;
}
}
</style>