#3577·emdash

With an Astro locale object, content created at runtime is stamped with the `path` while `Astro.currentLocale` is the code, so a lookup by the current locale misses it

Author: alanmacielCreated Sep 28, 2026Updated Sep 28, 2026
Labelsarea/corebot:workingbot:bug

Versions: emdash 0.42.0 and 1.0.1, @emdash-cms/cloudflare same, astro 7.3.2, astro dev on workerd.

Config

javascript
i18n: {
  defaultLocale: "es-MX",
  locales: ["es-MX", { path: "en", codes: ["en-US"] }],
  fallback: { en: "es-MX" },
  routing: { prefixDefaultLocale: false, fallbackType: "rewrite" },
}

Steps

  1. Seed a pages entry terminos-y-condiciones in es-MX.
  2. Create its translation through the REST API with the locale the admin offers for that entry, en (the locale list EmDash exposes is the normalized one, ["es-MX", "en"]): POST /_emdash/api/content/pages with { slug: "terminos-y-condiciones", locale: "en", translationOf: <id>, data: { title: "Terms EN" } }, then publish.
  3. On a page served under /en/, read Astro.currentLocale and query the entry with it.

Observed

  • Astro.currentLocale under /en/ is "en-US" (Astro returns the locale's first code).
  • getEmDashEntry("pages", "terminos-y-condiciones", { locale: "en-US" }) returns the es-MX row (via the fallback chain); { locale: "en" } returns "Terms EN".
  • The sitemap is consistent: sitemap-pages.xml lists /en/terminos-y-condiciones for the en row, and an en-US row is listed under /en/ too — resolveLocaleSegment matches entry.path === locale || entry.codes.includes(locale) since 0.42.0.

Expected

One locale identity per configured locale object across writes and reads: either rows are stamped with a code (so Astro.currentLocale finds them), or queries normalize a code to its object's path before matching. Today normalizeAstroI18n maps each object to its path (src/i18n/normalize.ts), which is what rows get, while Astro hands templates a code.

Workaround

Use string locales only, so the URL segment, Astro.currentLocale and the stored row locale are the same string.

(At 0.38.0 the sitemap side was broken as well — rows stamped with the path were dropped from it; that half is fixed in 0.42.0.)