Skip to content
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

Made change to support the meta._req object for precise Locale per request #57

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Maelstrom96
Copy link

This is to actually fix #34

I've made a test where I had a policy that had a setTimeout for 3 seconds before actually going forward to the controller. I tried calling the route with a header "accept-language: en" and before the timeout actually finished, I tried doing the same request with a different accept-language value and the result from the first request would the return in the language of the last request accept-language header value.

This fix is kind of a last resort but I was not sure how to implement it while keeping the same transparent implementation. Instead, I used the "metaContainer" value that is usually found has the 3rd parameter for the different methods and if you populate it with { _req: req }, it will use the request locale, else if meta._req is not populated, it will fallback to the old method.

I've also changed the "handle deferred where" piece of code because it wouldn't work with the current implementation and just ported the code block from the sails 0.12 codebase.

I might also create some additional tests to prove my point and also check that it's not breaking the default implementation of all the model methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Think about alternative to sails.config.i18n.requestLocale
1 participant