-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sails.hooks.views.render()
: Render view, in non request scope, do not take locale into account
#3833
Comments
I can confirm that with sails v0.11.5 it's working properly. |
I downgraded my sails (0.12.4) i18n module to version 0.5.0 (dependency of sails 0.11.5) and it works fine. |
This feature it's really important for my app, so when I find some time I'll try to find a solution and then send a PR. I want to update to sails v0.12 but I need this functionality running! |
@Josebaseba That'd be awesome! Talked to @dougwilson a little bit about this recently, but unfortunately it sounds like there's still a ways to go before views support will be ready to extrapolate from Express. In the mean time, if you're able to get this working, then we can make |
sails.hooks.views.render()
: Render view, in non request scope, do not take locale into account
Done 👍 #3889 |
Wonderful news, thanks a lot! |
[fixes #3833] Take locale into account in views.render()
@jberrisch please can you test it? For me it's working as it should, take a look and then we can close this issue. Thanks! |
@Josebaseba @jberrisch thanks guys! (Now published as 0.12.10) |
[fixes #3833] Take locale into account in views.render()
Sails version:0.12.4
Node version:4.5.0
NPM version:2.15.9
Operating system:Os X 10.11.6
I try to use a hook (sails-hook-cron) to send emails to customers who have different locales.
In this hook I use 'sails.hooks.views.render' to compile my email template.
This works quite fine but when I pass the locale as options it is ignored.
Here is a example hook to reproduce this error:
I got into the source code and at the ligne 102 of the file: node_modules/sails/lib/hooks/views/render.js the 'req.locale' is set to 'options.locale'.
But, ... the i18n module invoked at ligne 98 (require('i18n').init) overrides the 'options.locale' value.
So at ligne 102 it will always be set to the default locale because i18n guesses the value from the url-params / headers / cookies but never from the options.
By adding:
after ligne 97 (render.js) it works like expected, but I guess this is not very beautiful.
I tried to write a pull request and a test for this issue, but I had some trouble charging the i18n hook for the test because there's no sample configuration...
The text was updated successfully, but these errors were encountered: