Skip to content

Commit 174195a

Browse files
committed
Apply locale
1 parent d758ef5 commit 174195a

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

frontend/src/App.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script setup>
22
import {onMounted, ref} from 'vue'
33
import {useRoute, useRouter} from 'vue-router'
4-
import {useTheme} from 'vuetify'
4+
import {useLocale, useTheme} from 'vuetify'
55
import {useSQLite} from "@/composables/useSQLite.js";
66
import {useThemeStore} from '@/stores/theme'
7+
import {useLocaleStore} from '@/stores/locale'
78
import FileUploaderView from '@/components/FileUploaderView.vue'
89
import CoinListView from "@/components/CoinListView.vue";
910
import SettingsView from "@/components/SettingsView.vue";
@@ -29,9 +30,12 @@ const route = useRoute()
2930
3031
const themeStore = useThemeStore()
3132
const theme = useTheme()
33+
const localeStore = useLocaleStore()
34+
const appLocale = useLocale()
3235
3336
onMounted(async () => {
3437
theme.change(themeStore.currentTheme)
38+
appLocale.current.value = localeStore.currentLocale
3539
3640
await router.replace('/')
3741
})

frontend/src/components/SettingsView.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<script setup>
22
import {onMounted, onUnmounted, ref} from "vue";
3-
import { useTheme } from 'vuetify'
3+
import { useLocale, useTheme } from 'vuetify'
44
import { useLocaleStore } from '@/stores/locale'
55
import { useThemeStore } from '@/stores/theme'
66
77
const themeStore = useThemeStore()
8-
const localeStore = useLocaleStore()
98
const appTheme = useTheme()
9+
const localeStore = useLocaleStore()
10+
const appLocale = useLocale()
1011
1112
const langs = ref([
1213
{lang: 'bg', name: 'Български'},
@@ -40,6 +41,11 @@ onUnmounted(async () => {
4041
emit('update:title', oldTitle);
4142
})
4243
44+
const handleLocaleChange = (locale) => {
45+
localeStore.setLocale(locale)
46+
appLocale.current.value = locale
47+
}
48+
4349
const handleThemeChange = (theme) => {
4450
themeStore.setTheme(theme)
4551
appTheme.change(theme)
@@ -67,6 +73,7 @@ const handleThemeChange = (theme) => {
6773
:items="langs"
6874
item-title="name"
6975
item-value="lang"
76+
@update:model-value="handleLocaleChange"
7077
></v-select>
7178
</v-list-item>
7279
</v-list>

frontend/src/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as directives from 'vuetify/directives'
1212
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
1313
import colors from 'vuetify/util/colors'
1414
import { md3 } from 'vuetify/blueprints'
15+
import { bg, ca, de, el, es, fa, fr, it, nl, pl, pt, ru, tr, uk, } from 'vuetify/locale'
1516

1617
// Components
1718
import App from './App.vue'
@@ -24,6 +25,10 @@ const vuetify = createVuetify({
2425
components,
2526
directives,
2627
blueprint: md3,
28+
locale: {
29+
locale: 'en',
30+
messages: { bg, ca, de, el, es, fa, fr, it, nl, pl, pt, ru, tr, uk, },
31+
},
2732
theme: {
2833
defaultTheme: 'dark',
2934
themes: {

0 commit comments

Comments
 (0)