|
@@ -1,21 +1,44 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <label for="interface-language-switcher">
|
|
|
+ <div class="interface-language-switcher">
|
|
|
+ <label>
|
|
|
{{ promptText }}
|
|
|
</label>
|
|
|
- {{ ' ' }}
|
|
|
- <Select
|
|
|
- id="interface-language-switcher"
|
|
|
- v-model="controlledLanguage"
|
|
|
- >
|
|
|
- <option
|
|
|
- v-for="lang in languages"
|
|
|
- :key="lang.code"
|
|
|
- :value="lang.code"
|
|
|
+ <ul class="setting-list">
|
|
|
+ <li
|
|
|
+ v-for="index of controlledLanguage.keys()"
|
|
|
+ :key="index"
|
|
|
>
|
|
|
- {{ lang.name }}
|
|
|
- </option>
|
|
|
- </Select>
|
|
|
+ <label>
|
|
|
+ {{ index === 0 ? $t('settings.primary_language') : $tc('settings.fallback_language', index, { index }) }}
|
|
|
+ <Select
|
|
|
+ class="language-select"
|
|
|
+ :model-value="controlledLanguage[index]"
|
|
|
+ @update:modelValue="val => setLanguageAt(index, val)"
|
|
|
+ >
|
|
|
+ <option
|
|
|
+ v-for="lang in languages"
|
|
|
+ :key="lang.code"
|
|
|
+ :value="lang.code"
|
|
|
+ >
|
|
|
+ {{ lang.name }}
|
|
|
+ </option>
|
|
|
+ </Select>
|
|
|
+ </label>
|
|
|
+ <button
|
|
|
+ v-if="controlledLanguage.length > 1 && index !== 0"
|
|
|
+ class="button-default btn"
|
|
|
+ @click="() => removeLanguageAt(index)"
|
|
|
+ >
|
|
|
+ {{ $t('settings.remove_language') }}
|
|
|
+ </button>
|
|
|
+ </li>
|
|
|
+ <li>
|
|
|
+ <button
|
|
|
+ class="button-default btn"
|
|
|
+ @click="addLanguage"
|
|
|
+ >{{ $t('settings.add_language') }}</button>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -34,7 +57,7 @@ export default {
|
|
|
required: true
|
|
|
},
|
|
|
language: {
|
|
|
- type: String,
|
|
|
+ type: [Array, String],
|
|
|
required: true
|
|
|
},
|
|
|
setLanguage: {
|
|
@@ -48,7 +71,9 @@ export default {
|
|
|
},
|
|
|
|
|
|
controlledLanguage: {
|
|
|
- get: function () { return this.language },
|
|
|
+ get: function () {
|
|
|
+ return Array.isArray(this.language) ? this.language : [this.language]
|
|
|
+ },
|
|
|
set: function (val) {
|
|
|
this.setLanguage(val)
|
|
|
}
|
|
@@ -58,7 +83,30 @@ export default {
|
|
|
methods: {
|
|
|
getLanguageName (code) {
|
|
|
return localeService.getLanguageName(code)
|
|
|
+ },
|
|
|
+ addLanguage () {
|
|
|
+ this.controlledLanguage = [...this.controlledLanguage, '']
|
|
|
+ },
|
|
|
+ setLanguageAt (index, val) {
|
|
|
+ const lang = [...this.controlledLanguage]
|
|
|
+ lang[index] = val
|
|
|
+ this.controlledLanguage = lang
|
|
|
+ },
|
|
|
+ removeLanguageAt (index) {
|
|
|
+ const lang = [...this.controlledLanguage]
|
|
|
+ lang.splice(index, 1)
|
|
|
+ this.controlledLanguage = lang
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+@import '../../_variables.scss';
|
|
|
+
|
|
|
+.interface-language-switcher {
|
|
|
+ .language-select {
|
|
|
+ margin-right: 1em;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|