-
Notifications
You must be signed in to change notification settings - Fork 42
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
add locale parameter to links & forms which should include it #31
Conversation
Hey @mrbrdo, can you give some context on the PR? Specifically, what was going wrong/not working that your PR fixes? Would be useful for reviewing and testing on my end. Also, in general, thanks for the contributions :) I'm one of the devs that will be helping to maintain the spree code, it's great to have members of the community involved in the process 😎 |
@nciemniak well in general the localization functionality had a lot of problems for me. Many times while clicking around the site, the selected locale will be lost (as it is only saved in the URL itself).
In general a lot of issues and probably the worst part of the legacy frontend. But these are at least the most important ones. I'm definitely glad that you guys are processing PRs. I put a lot of work into fixing the issues I had for my own store and I appreciate it a lot that changes are being merged back upstream, so I don't have to maintain a fork with 100 changes. |
@mrbrdo we tried this on a few machines (running with Spree 4.5 beta), but we couldn't reproduce it - the redirects always persisted locale. What you described in the PR makes sense though - given that a better internationalization and content translations are part of the roadmap we should:
Would that make sense from your perspective? |
That's curious that you didn't have that issue. I did test that with 4.3.x but I don't remember that you did any changes to this functionality. If I have some time I may test again without these fixes, but even if then not this week (black friday and all). There are 2 problems or things to keep in mind with suggested approach:
I think the current approach is not completely flawed in this sense, the only issue is that there are places where the locale is left out. And that it's quite easy to forget about it. I'm not sure if saving the locale in db (or even cookies) for the user itself is necessarily the best way to go around it, although maybe it could be. The async email locale now works correctly for me, I think I fixed that with https://github.com/mrbrdo/better_spree_localization/blob/main/lib/better_spree_localization/core_ext/spree/order_decorator.rb and https://github.com/mrbrdo/better_spree_localization/blob/main/lib/better_spree_localization/railtie.rb#L66 or something else from that gem. With the changes in this PR + that gem I made I don't really observe any more issues with locale changing, so I think it's quite possible to fix it without changing the general approach. The gem is kinda a dirty hack though because it also monkeypatches the url helpers to add the locale under certain conditions - for a proper fix the url generation should be fixed in a better way. |
@mrbrdo have you added scope for locale in spree_auth_devise or somewhere else? I was trying to replicate your issue, but it only appeared after that, and also what you suggested fixed it. |
@wjwitek I don't understand what you mean, can you provide a specific example of how to add the scope, and I will check/try that? |
@mrbrdo Ok, to provide more context: I was trying to unify locale in url, since in login/registration etc. it was as param, not part of url itself, becouse everything to do with account is handled by spree/spree_auth_devise. So in spree_auth_devise's routes.rb I added scope like here: spree/spree_auth_devise#570 and that's when I started getting problems with lost locale as you've described. |
@wjwitek ok now I understand. I am using the main branch of |
@mrbrdo If you can reproduce these issues you had described on a clean copy of the spree app, let us know. For now we will hold off on merging your changes since the locale works as expected in login and search. |
@nciemniak ok, I will test it. We are talking about legacy frontend right? |
@mrbrdo yes, legacy frontend, correct 👍 |
@nciemniak I went to test with a spree_starter v4.5 fresh app and it seems these issues are indeed fixed and my commit seems not necessary. I have to test further with my app, if something comes up, I will let you know. I'm pretty sure these issues existed in 4.3.1 though, must have been fixed since. Good thing you are going through PRs faster now so this kind of situation will come up less in the future :) |
May need more of these in other places, but this fixed the most important stuff for me.