You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nginx-ui/app/src/components/SetLanguage/SetLanguage.vue

59 lines
1.0 KiB
Vue

<script setup lang="ts">
import { ref, watch } from 'vue'
import gettext from '@/gettext'
import { useSettingsStore } from '@/pinia'
import http from '@/lib/http'
const settings = useSettingsStore()
const route = useRoute()
const current = ref(gettext.current)
const languageAvailable = gettext.available
function init() {
if (current.value !== 'en') {
http.get(`/translation/${current.value}`).then(r => {
gettext.translations[current.value] = r
})
}
}
init()
watch(current, v => {
init()
settings.set_language(v)
gettext.current = v
const name = route.name as never as () => string
document.title = `${name()} | Nginx UI`
})
</script>
<template>
<div>
<ASelect
v-model:value="current"
size="small"
style="width: 60px"
>
<ASelectOption
v-for="(language, key) in languageAvailable"
:key="key"
:value="key"
>
{{ language }}
</ASelectOption>
</ASelect>
</div>
</template>
<style lang="less" scoped>
</style>