akkoma-fe/src/components/interface_language_switcher/interface_language_switcher.vue

73 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<div>
<FAIcon
v-if="globeIcon"
icon="globe"
/>
{{ ' ' }}
<label for="interface-language-switcher">
{{ promptText }}
</label>
2022-03-23 14:15:05 +00:00
{{ ' ' }}
<Select
id="interface-language-switcher"
v-model="controlledLanguage"
2019-07-05 07:17:44 +00:00
>
<option
v-for="lang in languages"
:key="lang.code"
:value="lang.code"
2019-07-05 07:17:44 +00:00
>
{{ lang.name }}
</option>
</Select>
</div>
</template>
<script>
import localeService from '../../services/locale/locale.service.js'
import Select from '../select/select.vue'
2019-07-05 07:17:44 +00:00
export default {
components: {
Select
},
props: {
promptText: {
type: String,
required: true
},
language: {
type: String,
required: true
},
setLanguage: {
type: Function,
required: true
},
globeIcon: {
type: Boolean,
default: true
}
},
2019-07-05 07:17:44 +00:00
computed: {
languages () {
return localeService.languages
2019-07-05 07:17:44 +00:00
},
controlledLanguage: {
get: function () { return this.language },
2019-07-05 07:17:44 +00:00
set: function (val) {
this.setLanguage(val)
}
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) {
return localeService.getLanguageName(code)
}
}
2019-07-05 07:17:44 +00:00
}
</script>