开发者

rails-I18n- when changing the locale, partials aren't translated

I am changing the locale in the app controller

before_filter :set_locale
def set_locale 
  I18n.locale = params[:hl] || I18n.default_locale 
end

for a Page that contains rendered partials and has a layout which yields th开发者_JAVA百科e menu items.

The static text from the Page is translated to the new locale, however the static text from the layout isn't, including the yielded menu items.

It looks like a threading issue.

Has someone encountered this behavior for I18n?


I found a workaround in setting the default_locale to the new locale in before_filter and in after_filter setting the default_locale back to its initial value.

But if someone accesses an instance of the site while for some other instance, ran by the user changing his locale, the after_filter hasn't been called yet it will display the wrong language (the new locale set)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜