potential fix for missing initial locale

This commit is contained in:
vcoppe
2024-06-20 00:28:16 +02:00
parent 866e50d765
commit 1ed28b7ada
2 changed files with 9 additions and 7 deletions

View File

@@ -40,7 +40,7 @@
updateSelectionFromKey updateSelectionFromKey
} from '$lib/stores'; } from '$lib/stores';
import { selectAll, selection } from '$lib/components/file-list/Selection'; 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 { canUndo, canRedo, dbUtils, fileObservers, settings } from '$lib/db';
import { anySelectedLayer } from '$lib/components/layer-control/utils'; import { anySelectedLayer } from '$lib/components/layer-control/utils';
import { defaultOverlays } from '$lib/assets/layers'; import { defaultOverlays } from '$lib/assets/layers';

View File

@@ -1,8 +1,8 @@
import type { Coordinates } from "gpx"; import type { Coordinates } from "gpx";
import { TrackPoint, distance } 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 { settings } from "$lib/db";
import { _ } from "svelte-i18n"; import { _, locale } from "svelte-i18n";
import { map } from "$lib/stores"; import { map } from "$lib/stores";
const { routing, routingProfile, privateRoads } = settings; const { routing, routingProfile, privateRoads } = settings;
@@ -20,11 +20,13 @@ export const routingProfileSelectItem = writable({
value: '', value: '',
label: '' 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) => { routingProfileSelectItem.update((item) => {
item.value = value; item.value = profile;
item.label = get(_)(`toolbar.routing.activities.${value}`); item.label = get(_)(`toolbar.routing.activities.${profile}`);
return item; return item;
}); });
} }