From 5e06fdb122e3951ddcf1c7a6a29ce75531331e45 Mon Sep 17 00:00:00 2001 From: grey-cat-1908 Date: Sun, 24 Mar 2024 20:04:31 +0300 Subject: [PATCH] fixed lang --- src/App.vue | 13 +++++++++++-- src/main.ts | 2 +- src/utils/i18n.ts | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index f56d810..60dc4cc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -33,7 +33,12 @@ let settings: Settings = new Settings(store.width, store.height); let map: Map; +import { useI18n } from "vue-i18n"; +const t = useI18n(); + onMounted(() => { + t.locale.value = localStorage.getItem('locale') || 'en'; + store.stations = [ {'name': 'Начало', 'up': true, 'connectedStations': [], 'step': 0}, {'name': 'Конец', 'up': true, 'connectedStations': [], 'step': store.width - 400} @@ -46,6 +51,10 @@ onMounted(() => { build(); }) +function setStorage(val) { + localStorage.setItem('locale', val); +} + function exportFile() { build(); @@ -168,8 +177,8 @@ store.$subscribe((mutation, state) => {

{{ $t("app.cursor") }}: ({{ xcord }}; {{ ycord }}) | {{ $t("app.about") }} | - English - Русский + English + Русский

diff --git a/src/main.ts b/src/main.ts index d3b37db..cc255b9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,6 +20,6 @@ const pinia = createPinia() const vuetify = createVuetify({ components, directives -}) +}); createApp(App).use(vuetify).use(pinia).use(i18n).mount('#app') \ No newline at end of file diff --git a/src/utils/i18n.ts b/src/utils/i18n.ts index 8bfbbe1..f55cf71 100644 --- a/src/utils/i18n.ts +++ b/src/utils/i18n.ts @@ -107,7 +107,8 @@ const messages = { // 2. Create i18n instance with options export const i18n = createI18n({ - locale: window.localStorage.getItem("locale") | 'ru', + legacy: false, + locale: 'ru', fallbackLocale: 'ru', messages })