From 1ed28b7ada1daa9e9dfe939054a3e89430f30784 Mon Sep 17 00:00:00 2001 From: vcoppe Date: Thu, 20 Jun 2024 00:28:16 +0200 Subject: [PATCH] potential fix for missing initial locale --- website/src/lib/components/Menu.svelte | 2 +- .../components/toolbar/tools/routing/Routing.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/website/src/lib/components/Menu.svelte b/website/src/lib/components/Menu.svelte index 3fbf809c..48a50455 100644 --- a/website/src/lib/components/Menu.svelte +++ b/website/src/lib/components/Menu.svelte @@ -40,7 +40,7 @@ updateSelectionFromKey } from '$lib/stores'; import { selectAll, selection } from '$lib/components/file-list/Selection'; - import { derived, get } from 'svelte/store'; + import { derived } from 'svelte/store'; import { canUndo, canRedo, dbUtils, fileObservers, settings } from '$lib/db'; import { anySelectedLayer } from '$lib/components/layer-control/utils'; import { defaultOverlays } from '$lib/assets/layers'; diff --git a/website/src/lib/components/toolbar/tools/routing/Routing.ts b/website/src/lib/components/toolbar/tools/routing/Routing.ts index 19a79bd0..268cc492 100644 --- a/website/src/lib/components/toolbar/tools/routing/Routing.ts +++ b/website/src/lib/components/toolbar/tools/routing/Routing.ts @@ -1,8 +1,8 @@ import type { Coordinates } from "gpx"; import { TrackPoint, distance } from "gpx"; -import { get, writable } from "svelte/store"; +import { derived, get, writable } from "svelte/store"; import { settings } from "$lib/db"; -import { _ } from "svelte-i18n"; +import { _, locale } from "svelte-i18n"; import { map } from "$lib/stores"; const { routing, routingProfile, privateRoads } = settings; @@ -20,11 +20,13 @@ export const routingProfileSelectItem = writable({ value: '', label: '' }); -routingProfile.subscribe((value) => { - if (value !== get(routingProfileSelectItem).value) { + +derived([routingProfile, locale], ([profile, l]) => [profile, l]).subscribe(([profile, l]) => { + console.log(profile, l); + if (profile !== get(routingProfileSelectItem).value && l !== null) { routingProfileSelectItem.update((item) => { - item.value = value; - item.label = get(_)(`toolbar.routing.activities.${value}`); + item.value = profile; + item.label = get(_)(`toolbar.routing.activities.${profile}`); return item; }); }