P
P
Pavel Kononenko2015-05-31 21:41:24
Nginx
Pavel Kononenko, 2015-05-31 21:41:24

In production, not all strings are updated when localization changes dynamically in a Rails application. Why?

In production, I use the NGINX + PASSENGER bundle.
I change the locales in the ApplicationController like this:
I18n.locale = current_user.locale rescue :en
However, not all phrases are translated into the newly installed locale until, for example, touch tmp/restart.txt is done. If you wait a while, refresh the page, then everything is seized. The problem does not always recur. What could it be? Is nginx caching? Rail buggy?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2015-06-01
@vsuhachev

As far as I can judge, your method insures you against an exception, but not from the "error-free" return of some crooked value from current_user.locale
I would write something like this

I18n.locale = ([current_user.try(:locale)] & [:en, :ru, :etc]).first || :en

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question