-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18n routing #701
Comments
Does this task have someone working on it, or would contributions be welcome? |
I'll champion it; this means I will manage the project and work on it full-time, but that doesn't mean that third-party contributions aren't welcome. This means that the project will have a boost with a defined release date. You're more than welcome to contribute; we can use Github/Discord as a coordination medium, and I will help with PR reviews and merge them in case there's some delay. Any help is appreciated! |
Awesome! This would make my Astro app a lot simpler 🙌 |
Excellent! I'm so stoked to see this moving forward, this is going to be a huge help for my clients, and should hopefully help with convincing more people to make the jump to the beautiful astro revolution. The initial work I did while experimenting on how this could be approached can be found here. I'm not sure how much of it will actually prove useful, as it was a pretty ramshackle approach I threw together, and I have a somewhat limited understanding of the inner working of Astro. I've joined the discord ( Once again, super stoked to see this moving forward, thank you for championing it for us all! 🎉 |
Interesting, I literally have a module that does most of the mentioned features, including:
and probably something else that I'm not remembering rn. Should I share the code? |
Feel free to do it @maddsua :) |
I'll just do that as gist for now. It's not really a single module at the moment, more like a bunch of stuff that just manages to work well enough https://gist.github.com/maddsua/45f014ed9d50701b89af48ed6a7795da |
I like the SSR version of it much more, that why I wasn't happy about Edge adapters being nuked, but let's not talk about it. |
For SSG mode, we just render all pages based on provided languages. |
Hey @ematipico 👋 Nice to see that Astro will treat internationalization as a first class concern 😄 while short-lived, I learned a lot from implementing and maintaining When you say localized routes, do you mean Another request that I implemented was
That’s great! I implemented several helpers to make this easier, but so long as you expose the i18n config, those will all work with minimal changes.
This is great! Will there also be the option to opt-out too?
Will the Astro sitemap integration automatically remove those default locale redirects from the final sitemap? |
The idea is that the majority of the features will be opt-in. The default functionalities will have to match the functionalities provided by
I don't have an answer to that because I don't know the integration well. What your take on this one? |
@ematipico after more research, while my solution may not be the answer, it does seem that the sitemap integration will need to update its
Still curious about that one |
That's something we plan to support, but not as part of the initial implementation. :) @jlarmstrongiv quick question for you: let's say we have a locale that misses a translated page - e.g.
|
I think this depends on how the developer is implementing the page. In most cases, you probably just want a regular old 404 as the default, to avoid encountering unpredicted quirks with hreflangs and SEO. For many pages, the page may not be relevant in another language - for example, a product only available in a specific region, or other content pertaining to the country in question. Fallback content is something that should be managed by the developer - if you're in a SSR context, you could define your own content fallbacks, or the CMS may provide a locale fallback order. In a SSG context, you'd define the behaviour during your getStaticPaths presumably? |
I tried to support it in my integration, but it’s extremely difficult to do without it being in the Astro core.
That’s a great point! Most of the developers who used my integration and made their project public had smaller sites and usually had their local language and English. They always provided all their translations for all their pages. But, I can definitely see that being necessary for large sites spanning many languages.
For my blog site, I’m currently using content collections to manage translations. So, if a content collection is missing a translation (which would happen once I add my wife’s native language), I would expect a temporary redirect to the default locale. But, for my application site, I’m using FormatJS exclusively. In that case, if just a couple translations are missing or need to be updated, I would render Plus, @SudoCat had great examples with products only available in certain countries. So, I suppose the answer is “it depends”. And if the developer has control of the rendering in an Astro page, it can know which locale its on, and what to do in all those cases:
Except the default locale prefix one |
Can users localize error pages? |
I can't speak to the other libraries mentioned here, but we've been using Starlight extensively for the past several months on https://beta.tauri.app and it's been really nice to use the i18n functionality the way it's built out there. I'm curious if you're envisioning this to be a solution for any Astro route created by a Super excited to see this one and more than happy to work with it and give some feedback along the way! 🥳 |
This would indeed make Astro way more interesting for agencies working on content / marketing websites. |
RFC Stage 3 now open |
Summary
First-class support for localized routes, aka i18n routing.
Background & Motivation
Many websites need to ship support for translated/localised websites for many reasons:
Nowadays there are workarounds in Astro to make it work, although these workarounds have limitations, and because of that many users can't ship their website properly, or they have to work more to compensate the lack of first-class support.
Goals
Accept-Language
header, so support SSR;.astro
components, endpoints, middleware);Non-Goals
The text was updated successfully, but these errors were encountered: