-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
feat: add option to only detect browser locale on root path #799
Conversation
58efa34
to
197cc89
Compare
Locale cookie isn't changed - that's definitely needed. Visit After that visit Visit -- Otherwise looks good! |
I'm not convinced. I would say that stored locale is something more of a user's choice and should remain at the original value even if user somehow ends-up loading page from another locale. In sites that I work with the locale is detected and store initially on the first visit and then the user can change it through a language selector. I'm not sure it should change on just visiting a page from another locale. |
First time user came from search engines to the page ending with That user definitely wanted It doesn't make sense to redirect again based on other factors when he definitely visited that page once before.
It's an user's choice that isn't kept at all which should be.
His first visit is from search engines directly to Also, any other i18n are just doing what I wrote and honors user choice on page visit. Thanks! |
That's the case when user visits the page for the first time and it makes sense what you are saying. I was more thinking about user that has already visited the page and then clicked a link to different locale (accidentally or was sent a link or something). Then I would consider changing his choice too invasive.
Isn't kept at all? I think it is currently at least. Excluding the initial navigation that sets the cookie based on browser locale, from there I think it doesn't change unless changed explicitly.
Do you have any references to other solutions that do that? |
It's not too invasive, see how Google handles this: Visit https://support.google.com/webmasters/?hl=fr (or Russian for example https://support.google.com/webmasters/?hl=ru) Close the window and visit https://support.google.com/webmasters/ Language was set to French by only visiting that url. Nobody mistakenly visits links, even if it happens user could change language later on - it's less annoying or invasive (it's not saved in database or not changing some config files 😄) .
Currently this behavior is a temporary fix for crawlers to see page content without redirection, however coming back user will be annoyed to be redirected to
Yes, kindly check this library probably it also answers some of the questions regarding prefix_except_default Thanks! |
Well, that's quite convincing but it would be quite a major behavior change for existing users so I'm not sure I can just enable that behavior by default. And tying it to the |
Maybe add a configuration option? I know that you've previously said that won't add some new configurations, however as you could see this definitely needed and everyone could just configure i18n as they want. Thanks! |
@rchl any update on this please? |
Sorry but I don't have much time and the time I have I prefer spending somewhere else right now. I'm not entirely happy about this change and it also needs more testing (in form of tests, for now). I'll get to it for sure and hopefully sooner than later. I can release it as beta if you want to try it. |
I can understand this is a major change, however a lot of people have requested this feature as well not sure why everyone went silent about this now. I've tested it, works perfectly except cookie not changing correctly. I would like to contribute but it's a bit hard with so many options included and still trying to figure out where to put that cookie change (use already written function or just write new one or refactor it at all). Releasing as beta might help to test it for everyone who needs this feature. Thank you again! |
@rchl sorry to bother you again, have you had a chance to find a time to think about this again? Like what might take you happy about this change? This is needed for prefixed strategies to be used primarily for seo optimization. I think that all users will agree for a change, because this is a number one reason to be in search engines, otherwise no reason to make site with different locales when site isnt visible in search engines at all. Anyways, I've tried to use this branch merged with the master, however it doesn't care about stored cookie at all and always redirects to default locale. Probably this started after that fix on initial load redirection #805 Thanks! |
Sorry for delaying this but this change feels like it needs a lot of uninterrupted attention from me so that I have the whole picture clear and manage to cover all cases. It could be that it's simpler case than I think of it and I'm just over complicating it... It's just hard to get into it. Especially as this last week was busy for me (not easy with a kid that had to say home). |
We also ran into this issue with a new site we are developing. The proposed option would solve our issue, but I'm wondering, should the locale in the url not always take precedence? In my view, if the user entered a url with a certain locale, he probably wanted to view the page in that locale? I understand that there is also the case where I follow a link with a certain locale, but I might want to see the page in a different locale. But I feel that, if the site owner would want the second use case to take precedence over the first, they would have chosen a no_prefix strategy? |
There are various strategies. Speccing behavior for each would help me progress here:
Expected (?) behavior with default
(Behavior above applies when the Does everyone agree with that? I'm not certain about the |
Thanks for the quick follow! These rules look sane to me. I'm wondering however, are you suggesting to drop the |
That's the behavior with |
@rchl just one kindly question, would it change cookie on visiting localized url ? #799 (comment)
Prefixed routes never should redirect, locale already here it doesn't make sense to try to detect anything (even cookie on that prefixed url)! Regarding Sorry, if I misunderstood it correctly, however what we're looking is indexed site links in search engines and honoring site locale by visiting prefixed url without giving zero information (cookie, browser language and etc). Thanks! |
Yes, makes sense to update the cookie when not redirecting.
I think we agree here then.
Yep. |
197cc89
to
7d6b4e0
Compare
@rchl sorry to ask, is this almost ready or something is left? Thanks! |
Feeling pretty sick this whole week. Planning to have a final look at the code as soon as possible. Wanted to go through https://github.com/mcamara/laravel-localization again as I remember I saw some interesting stuff while reading it but forgot what those were. |
Wishing you well. Looking forward to see when you'll feel better! Thanks! |
…ocale Don't attempt to detect browser's language when user (or crawler) goes directly to a page with a locale prefix if that locale is not the default one. This is to avoid redirecting user that potentially wanted to load that specific page rather than the one matching browser's language. Resolves #455 Resolves #761
7d6b4e0
to
05dcc8f
Compare
OK, I think I'm ready to let it go. Two potential concerns:
|
@rchl you're right, however there is no elegant solution for prefix_and_default , maybe adding a note about that it's really hard to give correct language or do some redirection which in fact affects SEO dramatically. Search engines dislikes whenever route redirection/content changes and it makes them sick. Basically for SEO optimized website important thing is static content URLs that always kept same, if it changes duplicates are created and pages will be removed after that. Hopefully I understood your concerns well. Thanks! |
Will release tomorrow morning so that I'm available if something breaks. |
Don't attempt to detect browser's language when user (or crawler) goes
directly to a page with a locale prefix. This is to avoid redirecting
user that potentially wanted to load that specific page rather than the
one matching browser's language.
Resolves #455
Resolves #761
TODO
onlyRedirectFromRoot
(per SEO / GoogleBot - Language Redirect's issue #761 (comment))