Switching a blog post to French leads to a 404, because the language menu links to a post URL that is never built

Abierto Apto para principiantes
#1,773 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
frontend

Línea de trabajo

Lee apps/outreach/src/components/layout/LanguageToggle.astro y sigue cómo usa el blog el selector en la página apps/outreach/src/pages/[locale]/blog/[slug].astro. Actualiza el comportamiento de los enlaces de idioma para que una publicación sin traducir lleve al índice del blog en el otro idioma, en lugar de a una URL de una publicación inexistente. Compila apps/outreach y verifica que cada enlace en francés de dist/en/blog/*/index.html resuelva a un archivo dentro de dist/.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Area: Outreach Bug Difficulty: Low Priority: Medium

On every blog post, choosing "FR" in the header's language menu leads to a 404. LanguageToggle builds the other-language link by swapping the locale prefix of the current URL, so /en/blog/<slug>/ becomes /fr/blog/<slug>/. A blog post is only built under the locale in its own language frontmatter. Both languages share one flat directory, so a translation would need a different filename and therefore a different slug. The swapped URL can never exist. All six posts are English today, so the French option on each of them is a dead link. That includes https://opendatacapture.org/fr/blog/open-data-capture-v2/, which returns 404 on the live site.

Where

apps/outreach/src/components/layout/LanguageToggle.astro:33-44:

<a ... href={new URL(Astro.url.href.replace(`/${resolvedLanguage}`, `/en`))}>en</a>
<a ... href={new URL(Astro.url.href.replace(`/${resolvedLanguage}`, `/fr`))}>fr</a>

apps/outreach/src/pages/[locale]/blog/[slug].astro:14-20 builds each post under one locale only:

const paths = posts.map((post) => ({
  params: {
    locale: post.data.language,
    slug: post.slug
  },

Reproduce

  1. Open https://opendatacapture.org/en/blog/open-data-capture-v2/.
  2. Open the language menu in the header and choose "FR".

Actual: the browser goes to /fr/blog/open-data-capture-v2/, which is the 404 page.
Expected: the French option leads to a page that exists, such as the French blog index /fr/blog/, which already tells readers that the content is available in English.

Tests

apps/outreach has no unit or Playwright suite, by decision (apps/outreach/AGENTS.md). Verify through the build: in dist/en/blog/*/index.html, the language menu's fr link resolves to a file under dist/.

Suggested fix

Let the page give the toggle its alternate URLs instead of deriving them from the path. Page already receives bilingual, so pass it on to Header and LanguageToggle. When a page is not bilingual, link the other language to that language's blog index (or disable that option, as the toggle already does on the 404 page). If translated posts are planned, add an optional translation: reference('blog') field to the post schema and link to it when it is set.

Lenguaje dominante
TypeScript
Estrellas
119
Forks
19
Merge medio
4 d 11 h
PR fusionados (30 d)
35

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DouglasNeuroInformatics/OpenDataCapture

Todos los issues de DouglasNeuroInformatics/OpenDataCapture

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.