Summary
In an i18n site, the Admin UI edit route can open the wrong locale variant when the URL identifier is a slug-like ID and another locale shares the same slug.
We hit this in an Astro/Cloudflare EmDash site with pages/about:
- English row:
id: "about", slug: "about", locale: "en"
- Arabic row:
id: "about-ar", slug: "about", locale: "ar", translationOf: "about"
Navigating directly to:
/_emdash/admin/content/pages/about
opened the Arabic row and made it difficult/impossible to select/edit the English row.
What appears to happen
The content list page is locale-aware and defaults to i18n.defaultLocale, but the content edit page does not validate/preserve a locale search param and calls:
fetchContent(collection, id)
which fetches:
/_emdash/api/content/pages/about
without ?locale=en.
Because EmDash permits duplicate slugs across locales, an unscoped slug lookup is ambiguous.
Expected behavior
When i18n is enabled, the Admin content edit route should pass the active locale through to content reads and writes, likely defaulting to manifest.i18n.defaultLocale when no explicit ?locale= is present.
Example:
/_emdash/api/content/pages/about?locale=en
Local workaround
We patched @emdash-cms/admin@0.14.0 locally to:
- accept
locale in the edit route search params
- compute
activeLocale = searchParams.locale ?? i18n.defaultLocale
- include locale in the single-content query key
- call
fetchContent(collection, id, { locale: activeLocale })
- pass
rawItem.locale ?? activeLocale to update/autosave calls
We also patched the API/runtime side so PUT requests with ?locale= use that locale when resolving slug-like IDs.
Version
Observed on EmDash 0.14.0 / @emdash-cms/admin@0.14.0.
Summary
In an i18n site, the Admin UI edit route can open the wrong locale variant when the URL identifier is a slug-like ID and another locale shares the same slug.
We hit this in an Astro/Cloudflare EmDash site with
pages/about:id: "about",slug: "about",locale: "en"id: "about-ar",slug: "about",locale: "ar",translationOf: "about"Navigating directly to:
opened the Arabic row and made it difficult/impossible to select/edit the English row.
What appears to happen
The content list page is locale-aware and defaults to
i18n.defaultLocale, but the content edit page does not validate/preserve alocalesearch param and calls:which fetches:
without
?locale=en.Because EmDash permits duplicate slugs across locales, an unscoped slug lookup is ambiguous.
Expected behavior
When i18n is enabled, the Admin content edit route should pass the active locale through to content reads and writes, likely defaulting to
manifest.i18n.defaultLocalewhen no explicit?locale=is present.Example:
Local workaround
We patched
@emdash-cms/admin@0.14.0locally to:localein the edit route search paramsactiveLocale = searchParams.locale ?? i18n.defaultLocalefetchContent(collection, id, { locale: activeLocale })rawItem.locale ?? activeLocaleto update/autosave callsWe also patched the API/runtime side so PUT requests with
?locale=use that locale when resolving slug-like IDs.Version
Observed on EmDash
0.14.0/@emdash-cms/admin@0.14.0.