-
Notifications
You must be signed in to change notification settings - Fork 10
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
Wrong locale redirection #161
Comments
I did a very simple reproduction: use crate::i18n::*;
use leptos::prelude::*;
use leptos_router::{components::*, StaticSegment};
#[component]
#[allow(non_snake_case)]
pub fn App() -> impl IntoView {
leptos_meta::provide_meta_context();
view! {
<I18nContextProvider>
<Router>
<Routes fallback=|| "Page not found.".into_view()>
<I18nRoute view=|| view! { <Outlet />} >
<Route path=StaticSegment("") view=HomePage/>
</I18nRoute>
</Routes>
</Router>
</I18nContextProvider>
}
}
#[component]
fn HomePage() -> impl IntoView {
let i18n = use_i18n();
move || i18n.get_locale().as_str()
} using the configs you gave me, and I'm not able to reproduce your issue, I even tried different browsers too. Yes an explicit segment does have the priority over everything, the Accept-Language header is only relevant when no locale segment is present see book |
I forgot to ask, is this CSR or SSR ? I only tried CSR |
Yes, that's what I read in the book as well. I'm using SSR with leptos 7rc1 and running |
I'm able to reproduce the bug with SSR, I'll fix it ASAP, Thx for reporting the issue ! |
What is happening is that the client use the |
I'll be pushing a new release very soon for leptos 0.7.0-rc1, it will contain the fix, for the timebeing you can use the latest commit on main (rev "aa28461" at the time of this comment) |
I just released |
That's awesome, thanks for the explaination and the quick fix ! |
Hi!
Thank you very much for this crate. I'll give as much context as possible.
With this being my i18n config:
And this my route config:
When I type
/nl
in my browser it immediately redirects to/en
while I would expect the Locale segment in the path to have priority (except when there is a cookie?)Additional info:
en
) or the entire cookie feature doesn't change anythingAccept-Language en-GB,en;q=0.5
I use the current main branch in my Cargo.toml:
leptos_i18n = { git = "https://github.com/Baptistemontan/leptos_i18n.git", rev = "b845a8c", default-features = false, features = ["nightly","track_locale_files","json_files"] }
This is set on a new project and fetching the translations works well.
The text was updated successfully, but these errors were encountered: