Show all languages in languagePickers if translation mode is on

This commit is contained in:
Pieter Vander Vennet 2024-05-06 15:18:29 +02:00
parent 91b836bf66
commit a856d8edc9
3 changed files with 19 additions and 11 deletions

View file

@ -94,6 +94,8 @@ import ImportReviewIdentity from "./Reviews/ImportReviewIdentity.svelte"
import LinkedDataLoader from "../Logic/Web/LinkedDataLoader" import LinkedDataLoader from "../Logic/Web/LinkedDataLoader"
import SplitRoadWizard from "./Popup/SplitRoadWizard.svelte" import SplitRoadWizard from "./Popup/SplitRoadWizard.svelte"
import DynLink from "./Base/DynLink.svelte" import DynLink from "./Base/DynLink.svelte"
import Locale from "./i18n/Locale"
import LanguageUtils from "../Utils/LanguageUtils"
class NearbyImageVis implements SpecialVisualization { class NearbyImageVis implements SpecialVisualization {
// Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests
@ -397,13 +399,18 @@ export default class SpecialVisualizations {
args: [], args: [],
docs: "A component to set the language of the user interface", docs: "A component to set the language of the user interface",
constr(state: SpecialVisualizationState): BaseUIElement { constr(state: SpecialVisualizationState): BaseUIElement {
return new SvelteUIElement(LanguagePicker, { return new VariableUiElement(
assignTo: state.userRelatedState.language, Locale.showLinkToWeblate.map(showTranslations => {
availableLanguages: state.layout.language, const languages = showTranslations ? LanguageUtils.usedLanguagesSorted : state.layout.language
preferredLanguages: state.osmConnection.userDetails.map( return new SvelteUIElement(LanguagePicker, {
(ud) => ud.languages assignTo: state.userRelatedState.language,
), availableLanguages: languages,
}) preferredLanguages: state.osmConnection.userDetails.map(
(ud) => ud.languages
),
})
})
)
}, },
}, },
{ {

View file

@ -18,7 +18,7 @@
EyeIcon, EyeIcon,
HeartIcon, HeartIcon,
MenuIcon, MenuIcon,
XCircleIcon, XCircleIcon
} from "@rgossiaux/svelte-heroicons/solid" } from "@rgossiaux/svelte-heroicons/solid"
import Tr from "./Base/Tr.svelte" import Tr from "./Base/Tr.svelte"
import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte" import CommunityIndexView from "./BigComponents/CommunityIndexView.svelte"
@ -73,6 +73,8 @@
import { BBox } from "../Logic/BBox" import { BBox } from "../Logic/BBox"
import ReviewsOverview from "./Reviews/ReviewsOverview.svelte" import ReviewsOverview from "./Reviews/ReviewsOverview.svelte"
import ExtraLinkButton from "./BigComponents/ExtraLinkButton.svelte" import ExtraLinkButton from "./BigComponents/ExtraLinkButton.svelte"
import Locale from "./i18n/Locale"
import LanguageUtils from "../Utils/LanguageUtils"
export let state: ThemeViewState export let state: ThemeViewState
let layout = state.layout let layout = state.layout
@ -138,7 +140,7 @@
const bottomRight = mlmap.unproject([rect.right, rect.bottom]) const bottomRight = mlmap.unproject([rect.right, rect.bottom])
const bbox = new BBox([ const bbox = new BBox([
[topLeft.lng, topLeft.lat], [topLeft.lng, topLeft.lat],
[bottomRight.lng, bottomRight.lat], [bottomRight.lng, bottomRight.lat]
]) ])
state.visualFeedbackViewportBounds.setData(bbox) state.visualFeedbackViewportBounds.setData(bbox)
} }

View file

@ -70,8 +70,7 @@ export default class Locale {
} }
if (!Utils.runningFromConsole) { if (!Utils.runningFromConsole) {
// @ts-ignore window["setLanguage"] = function (language: string) {
window.setLanguage = function (language: string) {
source.setData(language) source.setData(language)
} }
} }