aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/components/LanguageSelector.vue
blob: 0c47e6742888606a337b26110b935b9038e477c1 (plain)
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
<template>
    <el-select v-model="value" class="m-2" 
        :placeholder="$t('settings.language_select')" size="large"
        @change="onChange"
    >
        <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
        />
  </el-select>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { Store } from 'tauri-plugin-store-api';
const persistentStore = new Store('flight-core-settings.json');

export default defineComponent({
    name: 'LanguageSelector',
    data: () => ({
        value: '',
        options: [
            {
                value: 'en',
                label: 'English'
            },
            {
                value: 'fr',
                label: 'Français'
            },
            {
                value: 'de',
                label: 'Deutsch'
            },
            {
                value: 'es',
                label: 'Español'
            },
            {
                value: 'pl',
                label: 'polski'
            },
            {
                value: 'ru',
                label: 'русский'
            },
            {
                value: 'it',
                label: 'Italiano'
            },
            {
                value: 'da',
                label: 'Dansk'
            },
            {
                value: 'zh_Hans',
                label: '简体中文'
            },
        ]
    }),
    mounted: async function () {
        const lang: string = await persistentStore.get('lang') as string;
        this.value = lang;
    },
    methods: {
        async onChange(value: string) {
            this.$root!.$i18n.locale = value;
            persistentStore.set('lang', value);
            await persistentStore.save();
        }
    }
})
</script>