This commit is contained in:
@@ -16,13 +16,6 @@ const data = props.data;
|
||||
|
||||
const { locale } = useI18n();
|
||||
|
||||
|
||||
const changeLocale = (lang) => {
|
||||
console.log(lang);
|
||||
locale.value = lang.code;
|
||||
SetUserSetting('lang', lang.code);
|
||||
}
|
||||
|
||||
const id = data.id;
|
||||
|
||||
const rows = ref([{id: "account-settings", value: "settings.tabs.account-settings"}]);
|
||||
@@ -37,13 +30,40 @@ function getLocaleFromCode(code){
|
||||
}
|
||||
}
|
||||
|
||||
const selectedLocale = ref("");
|
||||
// The language to show in the dropdown: always one Dragonroll offers, because a
|
||||
// user that never picked one has none stored.
|
||||
function localeToShow(code){
|
||||
return getLocaleFromCode(code) || locales[0];
|
||||
}
|
||||
|
||||
// vue-i18n answers every translation with `SyntaxError: cannot support locale type`
|
||||
// once it is given a locale it has no messages for, and the locale is global: putting
|
||||
// a language that is not stored (the server answers `settings: undefined` for a user
|
||||
// that never picked one) or one no longer offered took the settings window and the
|
||||
// main menu behind it down (issue #47). Only known codes go into `locale`.
|
||||
function applyLanguage(code){
|
||||
const stored = getLocaleFromCode(code);
|
||||
if(!stored) return false;
|
||||
locale.value = stored.code;
|
||||
selectedLocale.value = stored;
|
||||
return true;
|
||||
}
|
||||
|
||||
const selectedLocale = ref(localeToShow(locale.value));
|
||||
|
||||
const changeLocale = (lang) => {
|
||||
if(!applyLanguage(lang?.code)) return;
|
||||
SetUserSetting('lang', lang.code);
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
GetUserSetting('lang').then(value => {
|
||||
locale.value = value;
|
||||
selectedLocale.value = getLocaleFromCode(value); // Set selected in dropdown
|
||||
});
|
||||
if(GetUser().admin) rows.value.push({
|
||||
// Set selected in dropdown. Without settings to read from the server the language
|
||||
// Dragonroll is already showing stays the one on screen.
|
||||
GetUserSetting('lang')
|
||||
.then((value) => applyLanguage(value))
|
||||
.catch(() => {});
|
||||
|
||||
if(GetUser()?.admin) rows.value.push({
|
||||
id: "site-administration",
|
||||
value: "settings.tabs.site-administration"
|
||||
});
|
||||
@@ -78,7 +98,7 @@ function OpenManageAccounts(){
|
||||
}
|
||||
|
||||
const getLocaleName = (locale) => {
|
||||
return locale.name;
|
||||
return locale ? locale.name : "";
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ClearWindow, GetFirstWindowId } from './Windows'
|
||||
import { ClearWindow, CreateWindow, GetFirstWindowId } from './Windows'
|
||||
|
||||
/*
|
||||
Put here all dragonroll windows
|
||||
@@ -26,7 +26,12 @@ const defWindows = {
|
||||
settings: {
|
||||
title: "windows.settings",
|
||||
component: () => import('~/components/windows/SettingsWindow.vue'),
|
||||
close: () => ClearWindow({type: 'settings'}),
|
||||
// The settings window is only opened from the main menu, so closing it goes back
|
||||
// there: CreateWindow leaves a window that is already open alone.
|
||||
close: () => {
|
||||
ClearWindow({ type: 'settings' });
|
||||
CreateWindow('main_menu');
|
||||
},
|
||||
movable: true
|
||||
},
|
||||
create_campaign: {
|
||||
|
||||
Reference in New Issue
Block a user