diff --git a/Logic/State/UserRelatedState.ts b/Logic/State/UserRelatedState.ts index 3dafd0c68..d18f53618 100644 --- a/Logic/State/UserRelatedState.ts +++ b/Logic/State/UserRelatedState.ts @@ -66,10 +66,6 @@ export default class UserRelatedState extends ElementsState { } }); - QueryParameters.GetBooleanQueryParameter("fs-translation-mode",false,"If set, will show the translation buttons") - .addCallbackAndRunD(tr => Locale.showLinkToWeblate.setData(Locale.showLinkToWeblate.data || tr)) - - this.changes = new Changes(this, layoutToUse?.isLeftRightSensitive() ?? false) @@ -126,6 +122,9 @@ export default class UserRelatedState extends ElementsState { if (layoutToUse === undefined) { return; } + if(Locale.showLinkToWeblate.data){ + return true; // Disable auto switching as we are in translators mode + } if (this.layoutToUse.language.indexOf(currentLanguage) < 0) { console.log( "Resetting language to", diff --git a/UI/LanguagePicker.ts b/UI/LanguagePicker.ts index 2945887c6..3d1437e55 100644 --- a/UI/LanguagePicker.ts +++ b/UI/LanguagePicker.ts @@ -4,22 +4,33 @@ import BaseUIElement from "./BaseUIElement"; import * as native from "../assets/language_native.json" import * as language_translations from "../assets/language_translations.json" import {Translation} from "./i18n/Translation"; +import * as used_languages from "../assets/generated/used_languages.json" +import Lazy from "./Base/Lazy"; +import Toggle from "./Input/Toggle"; export default class LanguagePicker { public static CreateLanguagePicker( languages: string[], - label: string | BaseUIElement = "") { + label: string | BaseUIElement = "") : BaseUIElement{ if (languages === undefined || languages.length <= 1) { return undefined; } - return new DropDown(label, languages.map(lang => { + const allLanguages : string[] = used_languages.languages; + + const normalPicker = LanguagePicker.dropdownFor(languages, label); + const fullPicker = new Lazy(() => LanguagePicker.dropdownFor(allLanguages, label)) + return new Toggle(fullPicker, normalPicker, Locale.showLinkToWeblate) + } + + private static dropdownFor(languages: string[], label: string | BaseUIElement): BaseUIElement { + return new DropDown(label, languages.map(lang => { return {value: lang, shown: LanguagePicker.hybrid(lang) } } - ), Locale.language); + ), Locale.language) } private static hybrid(lang: string): Translation { diff --git a/UI/i18n/Locale.ts b/UI/i18n/Locale.ts index 47e99c110..21f950501 100644 --- a/UI/i18n/Locale.ts +++ b/UI/i18n/Locale.ts @@ -6,8 +6,8 @@ import {QueryParameters} from "../../Logic/Web/QueryParameters"; export default class Locale { + public static showLinkToWeblate: UIEventSource = new UIEventSource(false); public static language: UIEventSource = Locale.setup(); - public static showLinkToWeblate: UIEventSource = new UIEventSource(false); private static setup() { const source = LocalStorageSource.Get('language', "en"); @@ -20,6 +20,13 @@ export default class Locale { QueryParameters.GetQueryParameter("language", undefined, "The language to display mapcomplete in. Will be ignored in case a logged-in-user did set their language before. If the specified language does not exist, it will default to the first language in the theme."), true ) + QueryParameters.GetBooleanQueryParameter("fs-translation-mode",false,"If set, will show the translation buttons") + .addCallbackAndRunD(tr => { + console.log("Query parameter for translation mode is", tr) + Locale.showLinkToWeblate.setData(Locale.showLinkToWeblate.data || tr); + }) + + } return source; }