Skip to content

Update i18n recipe to use built-in routing - #14304

Draft
hugosmoreira wants to merge 1 commit into
withastro:mainfrom
hugosmoreira:docs/update-i18n-recipe-api
Draft

Update i18n recipe to use built-in routing#14304
hugosmoreira wants to merge 1 commit into
withastro:mainfrom
hugosmoreira:docs/update-i18n-recipe-api

Conversation

@hugosmoreira

@hugosmoreira hugosmoreira commented Jul 26, 2026

Copy link
Copy Markdown

Description (required)

This updates the i18n recipe with a step-by-step English and French example using Astro's built-in routing. It keeps the recipe aligned with current content collections and i18n APIs while preserving translated routes and localized content.

The revision:

  • adds the required loader for the local content collection;
  • uses Astro.currentLocale for localized UI and date formatting;
  • uses an explicit route map for translated slugs such as /en/about/ and /fr/a-propos/;
  • connects navigation, the language picker, layouts, and localized blog content;
  • documents both static and SSR implementations.

Validation performed:

  • Generated standalone static and SSR fixtures from the final recipe snippets using Astro 7.0.2 from this repository's lockfile.
  • Both fixtures passed astro check with no errors, warnings, or hints.
  • Static output assertions verified localized routes, content, dates, lang attributes, and reciprocal hreflang links.
  • SSR development-server HTTP assertions verified the //en/ redirect, successful localized responses, translated routes and content, localized dates, reciprocal links, and the expected /fr/about/ 404.
  • Isolated controls confirmed the missing-loader failure and the broken raw-path language-picker behavior.
  • A fresh clone of the Astro 7.1.5 reproduction passed npm ci, astro check, and the static build; npm ci reported no vulnerabilities.
  • Browser verification of the published demo confirmed the root redirect, both-direction language switching for the about and blog pages, localized content and dates, reciprocal language links, and the expected invalid-route 404.
  • The documentation formatter, slug checker, ESLint, Astro check, full docs build, and link checker passed locally.

Live demo: https://hugosmoreira.github.io/astro-i18n-recipe-demo/

Source: https://github.com/hugosmoreira/astro-i18n-recipe-demo

References

@astrobot-houston

astrobot-houston commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/recipes/i18n.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@astrobot-houston

Copy link
Copy Markdown
Contributor

Hello! Thank you for opening your first PR to Astro’s Docs! 🎉

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any broken links you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Netlify 🥳.

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@hugosmoreira
hugosmoreira marked this pull request as ready for review July 26, 2026 06:33
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Preview deployment

✅ Deployment complete!

@ArmandPhilippot ArmandPhilippot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hugosmoreira,

First thanks for willing to help but...

We have a PR template so that contributors use it, not so an AI can replace it with whatever it pleases. The fact that your AI runs git diff --check is not important information for maintainers. Explaining what you changed and why you made those changes is more useful.

Also, have you tested your changes, or everything is AI-generated?

Your AI claims it's complete, but it doesn't seem to me. For example:

  • we still miss a loader
  • you removed the "Translate routes" section, but now the recipe no longer explains to users how to translate them... The current recipe do not translate any slugs.

If some info was missing in the previous recipe, it should be fixed. If we remove a section because there is another way to handle it, we should make sure the recipe still show how to achieve that.

The live recipe has several gaps. Using Astro built-in APIs is nice but I'm not sure that's enough to close that issue.

The purpose of a recipe is to provide step-by-step instructions to achieve a goal that users can adapt to their project. Looking at the end result, this just show users they can switch between two languages:

Result at the end of the recipe

A real demo of the result achieved with this recipe would be more useful, I think...

@hugosmoreira
hugosmoreira marked this pull request as draft July 28, 2026 15:53
@hugosmoreira

Copy link
Copy Markdown
Author

Thanks for the direct feedback. You're right: I replaced the PR template and described the recipe as complete without verifying the exact instructions end to end.

I used an AI assistant to help draft the change, but I'm responsible for reviewing and testing what I submit. I've returned the PR to draft. Before requesting another review, I'll restore the template, add the missing loader, preserve translated-slug support, and follow the complete recipe in a clean project with a runnable reproduction.

I'll report only the exact behavior I verified with the revision.

@hugosmoreira
hugosmoreira force-pushed the docs/update-i18n-recipe-api branch from da064ef to 8e41e1c Compare July 28, 2026 18:22
@hugosmoreira

Copy link
Copy Markdown
Author

Thanks for the direct feedback. You were right: the previous revision and PR description overstated what had actually been verified.

Codex assisted with the implementation. For this revision, I reviewed the final one-file diff and kept only claims backed by actual checks. The recipe now includes the missing content loader, preserves translated slugs with an explicit route map (/en/about//fr/a-propos/), connects the navigation and language picker to the demonstrated pages, and includes localized content examples for static and SSR rendering.

I generated standalone fixtures from the final snippets and tested the static output, SSR development-server responses, root redirect, localized routes/content/dates, reciprocal language links, and the missing-loader and raw-path-picker failure modes. I also published and browser-checked a fresh-clone reproduction:

I restored the repository's PR template and kept the PR as a draft for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants