From afb13a151bde2f52b7ccb67c17f7eb84581bd7a6 Mon Sep 17 00:00:00 2001 From: doxa-maps Date: Mon, 28 Sep 2026 06:55:27 +0000 Subject: [PATCH] Maps and /embed-test plugins get DX-life's locale (it is in the path, which they cannot read) --- app/components/DoxaMapSlot.vue | 5 ++++- app/pages/embed-test.vue | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/components/DoxaMapSlot.vue b/app/components/DoxaMapSlot.vue index f11db8d5..bbfb6b4b 100644 --- a/app/components/DoxaMapSlot.vue +++ b/app/components/DoxaMapSlot.vue @@ -37,9 +37,12 @@ onMounted(() => { * site: without assetsBase the bundle would look for them under this page's ./assets. */ const runtimeConfig = useRuntimeConfig() const dxMapsBase = ((runtimeConfig.public as { dxMapsBase?: string }).dxMapsBase || '').replace(/\/+$/, '') || '/dx-maps' +/* The site's language (it lives in the URL path, /ar/pray, which the map cannot read) goes to the map as + * its locale, so its text, direction and data follow DX-life's language and its switcher. */ +const { locale } = useI18n() const effectiveConfig = computed(() => { try { - const cfg = { assetsBase: `${dxMapsBase}/assets`, ...JSON.parse(props.profileConfig) } + const cfg = { assetsBase: `${dxMapsBase}/assets`, locale: locale.value, ...JSON.parse(props.profileConfig) } return JSON.stringify(cfg.tk ? cfg : { ...cfg, provider: 'maplibre' }) } catch { return props.profileConfig diff --git a/app/pages/embed-test.vue b/app/pages/embed-test.vue index fe679146..4dc00974 100644 --- a/app/pages/embed-test.vue +++ b/app/pages/embed-test.vue @@ -27,6 +27,7 @@ interface Card { const runtimeConfig = useRuntimeConfig() const route = useRoute() +const { locale } = useI18n() // the site's language, handed to every plugin (it is in the path, not ?lang) const cards = ref([]) const status = ref('Reading the manifest…') const hosts = new Map() @@ -67,11 +68,13 @@ async function mount(card: Card) { el.setAttribute('profile-config', JSON.stringify({ profile: card.profile, assetsBase: `${treeBase()}/assets`, + locale: locale.value, // with a Mapbox token the maps use it; without one they use the keyless MapLibre engine ...(token ? { tk: token } : { provider: 'maplibre' }) })) // shells (the Research Gallery, Plugin Studio) find their child maps through the tree's manifest el.setAttribute('tree-base', treeBase()) + el.setAttribute('language', locale.value) // the shells read their language from this attribute host.replaceChildren(el) card.state = 'mounted' } catch (e) {