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

How to localize your app suggests Padrino.before_load but app locales are not loaded yet #109

Closed
sshaw opened this issue Sep 6, 2016 · 4 comments

Comments

@sshaw
Copy link
Contributor

sshaw commented Sep 6, 2016

The docs recommends one use Padrino.before_load but when this runs app/locale has not been loaded, so assigning a locale that's not part of Padrino will result in a failure even though the locale is configured in app/locale.

The right way to go about the seems to be via the app's configure hook just adding the local locales to I18n.load_path yourself in before_load or configure.

@adam12
Copy link
Collaborator

adam12 commented Nov 21, 2016

I was just looking at this,

The load path for the locales is setup in the setup_locale method, called during setup_application!.

Unfortunately, It's called much later than both before_load and after_load, so I can't see either of those hooks working.

Calling I18n.load_path manually works, but you lose some of the special sauce provided by the Padrino reloader.

@sshaw
Copy link
Contributor Author

sshaw commented Feb 11, 2017

It's also worth noting that setting I18n.locale to :de in before_load will not actually set the request's locale to :de. I18n stores the locale in thread local storage and in most (all?) cases the before_load thread is different than the Rack handler's.

@sshaw
Copy link
Contributor Author

sshaw commented Feb 11, 2017

Fixed by #127.

@sshaw sshaw closed this as completed Feb 11, 2017
@wikimatze
Copy link
Member

Thanks @sshaw for fixing the issues with the locales.

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

No branches or pull requests

3 participants