Maps and /embed-test plugins get DX-life's locale (it is in the path, which they cannot read)

This commit is contained in:
doxa-maps 2026-09-28 06:55:27 +00:00
parent 6444a05203
commit afb13a151b
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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<Card[]>([])
const status = ref('Reading the manifest…')
const hosts = new Map<string, HTMLElement>()
@ -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) {