From a856d8edc93d08452c0e836c1ad560663a72d51c Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 6 May 2024 15:18:29 +0200 Subject: [PATCH] Show all languages in languagePickers if translation mode is on --- src/UI/SpecialVisualizations.ts | 21 ++++++++++++++------- src/UI/ThemeViewGUI.svelte | 6 ++++-- src/UI/i18n/Locale.ts | 3 +-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index 7b8534195..d2437a527 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -94,6 +94,8 @@ import ImportReviewIdentity from "./Reviews/ImportReviewIdentity.svelte" import LinkedDataLoader from "../Logic/Web/LinkedDataLoader" import SplitRoadWizard from "./Popup/SplitRoadWizard.svelte" import DynLink from "./Base/DynLink.svelte" +import Locale from "./i18n/Locale" +import LanguageUtils from "../Utils/LanguageUtils" class NearbyImageVis implements SpecialVisualization { // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests @@ -397,13 +399,18 @@ export default class SpecialVisualizations { args: [], docs: "A component to set the language of the user interface", constr(state: SpecialVisualizationState): BaseUIElement { - return new SvelteUIElement(LanguagePicker, { - assignTo: state.userRelatedState.language, - availableLanguages: state.layout.language, - preferredLanguages: state.osmConnection.userDetails.map( - (ud) => ud.languages - ), - }) + return new VariableUiElement( + Locale.showLinkToWeblate.map(showTranslations => { + const languages = showTranslations ? LanguageUtils.usedLanguagesSorted : state.layout.language + return new SvelteUIElement(LanguagePicker, { + assignTo: state.userRelatedState.language, + availableLanguages: languages, + preferredLanguages: state.osmConnection.userDetails.map( + (ud) => ud.languages + ), + }) + }) + ) }, }, { diff --git a/src/UI/ThemeViewGUI.svelte b/src/UI/ThemeViewGUI.svelte index 03e7f12ff..ed16c8303 100644 --- a/src/UI/ThemeViewGUI.svelte +++ b/src/UI/ThemeViewGUI.svelte @@ -18,7 +18,7 @@ EyeIcon, HeartIcon, MenuIcon, - XCircleIcon, + XCircleIcon } from "@rgossiaux/svelte-heroicons/solid" import Tr from "./Base/Tr.svelte" import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte" @@ -73,6 +73,8 @@ import { BBox } from "../Logic/BBox" import ReviewsOverview from "./Reviews/ReviewsOverview.svelte" import ExtraLinkButton from "./BigComponents/ExtraLinkButton.svelte" + import Locale from "./i18n/Locale" + import LanguageUtils from "../Utils/LanguageUtils" export let state: ThemeViewState let layout = state.layout @@ -138,7 +140,7 @@ const bottomRight = mlmap.unproject([rect.right, rect.bottom]) const bbox = new BBox([ [topLeft.lng, topLeft.lat], - [bottomRight.lng, bottomRight.lat], + [bottomRight.lng, bottomRight.lat] ]) state.visualFeedbackViewportBounds.setData(bbox) } diff --git a/src/UI/i18n/Locale.ts b/src/UI/i18n/Locale.ts index 9b3de8adb..926df4aa4 100644 --- a/src/UI/i18n/Locale.ts +++ b/src/UI/i18n/Locale.ts @@ -70,8 +70,7 @@ export default class Locale { } if (!Utils.runningFromConsole) { - // @ts-ignore - window.setLanguage = function (language: string) { + window["setLanguage"] = function (language: string) { source.setData(language) } }