fix: refs #7189 update user language on sessionStorage
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
21ebc85405
commit
adbb574025
|
@ -1,9 +1,11 @@
|
||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
import messages from 'src/i18n';
|
import messages from 'src/i18n';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
const user = useState().getUser();
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
locale: navigator.language || navigator.userLanguage,
|
locale: user.value.lang || navigator.language || navigator.userLanguage,
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'en',
|
||||||
globalInjection: true,
|
globalInjection: true,
|
||||||
messages,
|
messages,
|
||||||
|
|
|
@ -87,10 +87,10 @@ async function saveDarkMode(value) {
|
||||||
async function saveLanguage(value) {
|
async function saveLanguage(value) {
|
||||||
const query = `/VnUsers/${user.value.id}`;
|
const query = `/VnUsers/${user.value.id}`;
|
||||||
try {
|
try {
|
||||||
await axios.patch(query, {
|
await axios.patch(query, { lang: value });
|
||||||
lang: value,
|
|
||||||
});
|
|
||||||
user.value.lang = value;
|
user.value.lang = value;
|
||||||
|
useState().setUser(user.value);
|
||||||
onDataSaved();
|
onDataSaved();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
onDataError();
|
onDataError();
|
||||||
|
|
Loading…
Reference in New Issue