-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Astro v3: Recent injectRoute
changes broke integration astro-i18n-aut
#8241
Comments
Broken in the latest v3 as well:
|
injectRoute
changes broke integration astro-i18n-aut
injectRoute
changes broke integration astro-i18n-aut
Yes the changes from those PRs you mentioned are also in v3. I haven't had a chance to look at this yet with all the v3 launch stuff coming it, but I hope we can get this fixed soon. Generally the Will keep this issue updated when I get a chance to dig into it. |
Hiya @natemoo-re, I’m just wondering if you have any updates for this issue. I was hoping to close it as the i18n routing RFC was released as an experiment, but it doesn’t support the use case that I and others using my i18n package are looking for (1, 2, 3, etc.). With the proposal, we need to include a
In the
Optionally, the integration can also manage pages by fetching data from content collections or your API of choice.
The Since the i18n routing RFC does not support this use case, this issue has become more important, as we need it resolved to support it in the Astro ecosystem. Unfortunately, without this bug fix, it is not possible to support the use case with Astro integrations, middleware, or other existing hooks. |
@jlarmstrongiv I agree with you, the way you handled i18n still seem the best way to do it, when I saw the announcement on the blog page it made me confused, I was expecting a behaviours similar to this integration but from what I could read, it looked like it only introdcued an helper to calculate the url path of the locale where you're at, I didn't dig into it and I'm sure it does more than that (it's also experimental), but from the blog article I didn't saw the benefit of that implementation. I m thinking this is just a transation point for having a full featured integrated i18n solution but would have be nice if they mentioned the long term route in the article. My ideal native astro i18n would look like this
i18n: {
defaultLocale: "en",
locales: ["es", "en"]
}
// en.json
{
"hello": "Hello",
"goodbye": "Goodbye"
} // es.json
{
"hello": "Hola",
}
---
import { t, getLocaleUrlPrefix } from "astro-i18n-aut";
---
<span>{t.hello}</span>
Probably this solution does not accommodate everyone, but would be nice to have something similar as an option, until then the @jlarmstrongiv 's solution looks like the best way to go for me and this bug it's pretty annoying as it make harder to test changes on local environment. |
@zanhk and others, if you would like to see Astro support multiple i18n locales in a single Astro file in core, I encourage you to leave constructive comments, suggestions, and 👍’s in the i18n routing RFC—they are currently gathering feedback and it’d be great for you to share yours. Let’s leave this issue specifically for the Still leave 👍’s here for visibility too! Thanks for you consideration and support |
One thing I will add is that some adapters, like |
Regarding the idea of choosing the locale dynamically for a single document, I think it makes sense in some cases (applications), but in others it would be a hindrance. I speak many languages and I've lived in many different countries, and the experience of seeing how the website forces a language while not letting you choose explicitly is f%% horrible. As a user, for "content" sites, I very much prefer an automatic redirect from |
@castarco feel free to leave your feedback about your preferred i18n routing experience in the i18n routing RFC This issue is focused on |
I wish the reproduction would be minimal, meaning it shouldn't use another library to replicate the issue, because I would like to see the I'm willing to help and triage the issue, but I'd need to understand if this is allowed, or if we fixed a bug you were leveraging. |
@ematipico please see this minimal reproduction https://github.com/jlarmstrongiv/astro-routing-error please ensure you are on the latest commit for the simplified integration {
name: "astro-routing-bug",
hooks: {
"astro:config:setup": async ({ injectRoute }) => {
injectRoute({
entrypoint: path.join(process.cwd(), "src/pages/blog/[post].astro"),
pattern: "/es/blog/[post]",
});
injectRoute({
entrypoint: path.join(process.cwd(), "src/pages/blog/[post].astro"),
pattern: "/fr/blog/[post]",
});
},
},
}, The bug is about It worked great for many versions, but broke unexpectedly in a patch sometime between 2.8.0 and 2.10.14 If you are certain that this is not allowed, please let me know and I will archive astro-i18n-aut. There are no other ways with current Astro apis (even with experimental features) to support i18n with a default locale, without duplicating Astro files for every route. Regardless of whether the solution is in userland or core, it’s important to many users (myself included) to support this use case. I personally think this should be categorized as a bug, since it broke between Astro minor versions and not allowing the same |
I wonder if this is related to zankhq/astro-starter#23 and rawr51919/portfolio-2024#11 There I'm having a very similar issue where if I click on the language I want to display in and then back to the default, it uses the language's prefix instead of none in the URL (in the case of english, /en/ instead of /). the only fix at the moment is hardcoding every /en/ route as a redirect, wildcard redirects don't work at all |
I'll look into it |
Here's some updates:
Although, I can see a possible fix on your side while I figure out if there's an efficient caching strategy. |
thanks, i wonder if the bugfix also applies to my own astro site |
@rawr51919 I don't know, I fixed the issue based on the minimal repository that was shared here. |
might be vercel's end, i'll take a look in a lil |
Thank you @ematipico 👍 I will give it a try in the latest release |
Just to confirm, this cache fix is applied to both |
Astro info
What browser are you using?
Chrome
Describe the Bug
Has the behavior of
injectRoute
changed substantially in the last month or so? It seems to have broken my translation integration jlarmstrongiv/astro-i18n-aut#19Recent changes @natemoo-re:
injectRoute
works during build #7986injectRoute
#7943It seems that the astro dev server no longer supports using
injectRoute()
with the sameentryPoint
multiple times, specifically when theentryPoint
has dynamic paths like[slug].astro
.For example,
src/pages/blog/[slug].astro
is used as theentryPoint
for with the default page, but is also injected with apattern
that has a locale prefix like/es/
It works fine when the
entryPoint
andpattern
doesn’t have any dynamic path portions, likesrc/pages/about.astro
On the first load, whichever
pattern
is loaded always works. But, trying to use anotherpattern
that uses the sameentryPoint
results in an error:Would this be a core astro bug? Are there any alternatives to get the same functionality?
What's the expected result?
The correct page loads instead of returning 404.
Link to Minimal Reproducible Example
jlarmstrongiv/astro-i18n-aut#19
Participation
The text was updated successfully, but these errors were encountered: