My Rails application is on rails 4.0.2, and I have the problem of switching translations with the variable locale and params[:locale] from the URL scheme following the official guide rails. I have a one page site on my site .
My routes for internationalization:
scope "(:locale)", locale: /en|de/ do
My application controller
before_filter :set_locale def set_locale I18n.locale = params[:locale] || I18n.default_locale
Links for changing locale variables in a view:
<%= link_to_unless I18n.locale == :en, "English", locale: :en %> | <%= link_to_unless I18n.locale == :de, "Deutsch", locale: :de %>
What happens: the locale variable is set correctly, but the translations do not switch. If I delete one of the translation files (currently for English and German), the languages ββswitch to the remaining translation file. When I return another translation file and try to switch to it by changing the locale variable, it never switches to another language.
Why doesn't my code change translations?
source share