2018-08-25 10:12:33 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2018-12-05 08:37:01 +00:00
|
|
|
<label for="interface-language-switcher">
|
|
|
|
{{ $t('settings.interfaceLanguage') }}
|
|
|
|
</label>
|
2019-07-05 07:17:44 +00:00
|
|
|
<label
|
|
|
|
for="interface-language-switcher"
|
|
|
|
class="select"
|
|
|
|
>
|
|
|
|
<select
|
|
|
|
id="interface-language-switcher"
|
|
|
|
v-model="language"
|
|
|
|
>
|
|
|
|
<option
|
|
|
|
v-for="(langCode, i) in languageCodes"
|
2019-07-06 21:54:17 +00:00
|
|
|
:key="langCode"
|
2019-07-05 07:17:44 +00:00
|
|
|
:value="langCode"
|
|
|
|
>
|
2018-08-25 10:12:33 +00:00
|
|
|
{{ languageNames[i] }}
|
|
|
|
</option>
|
|
|
|
</select>
|
2020-10-20 21:31:16 +00:00
|
|
|
<FAIcon
|
|
|
|
class="select-down-icon"
|
|
|
|
icon="chevron-down"
|
|
|
|
/>
|
2018-08-25 10:12:33 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-07-05 07:17:44 +00:00
|
|
|
import languagesObject from '../../i18n/messages'
|
|
|
|
import ISO6391 from 'iso-639-1'
|
|
|
|
import _ from 'lodash'
|
2020-10-20 18:03:46 +00:00
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import {
|
|
|
|
faChevronDown
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faChevronDown
|
|
|
|
)
|
2018-08-25 10:12:33 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
languageCodes () {
|
2020-06-08 15:22:07 +00:00
|
|
|
return languagesObject.languages
|
2019-07-05 07:17:44 +00:00
|
|
|
},
|
2018-08-25 10:12:33 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
languageNames () {
|
|
|
|
return _.map(this.languageCodes, this.getLanguageName)
|
|
|
|
},
|
2018-08-25 10:12:33 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
language: {
|
2019-10-06 20:28:30 +00:00
|
|
|
get: function () { return this.$store.getters.mergedConfig.interfaceLanguage },
|
2019-07-05 07:17:44 +00:00
|
|
|
set: function (val) {
|
|
|
|
this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val })
|
2018-08-25 10:12:33 +00:00
|
|
|
}
|
2019-07-05 07:17:44 +00:00
|
|
|
}
|
|
|
|
},
|
2019-05-29 05:31:03 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
methods: {
|
|
|
|
getLanguageName (code) {
|
|
|
|
const specialLanguageNames = {
|
2019-11-16 16:11:19 +00:00
|
|
|
'ja': 'Japanese (日本語)',
|
|
|
|
'ja_easy': 'Japanese (やさしいにほんご)',
|
2021-01-01 02:53:16 +00:00
|
|
|
'zh': 'Simplified Chinese (简体中文)',
|
|
|
|
'zh_Hant': 'Traditional Chinese (繁體中文)'
|
2019-05-29 05:31:03 +00:00
|
|
|
}
|
2019-07-05 07:17:44 +00:00
|
|
|
return specialLanguageNames[code] || ISO6391.getName(code)
|
2018-08-25 10:12:33 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-05 07:17:44 +00:00
|
|
|
}
|
2018-08-25 10:12:33 +00:00
|
|
|
</script>
|