Using I18n for Ruby on Rails 4.0.0 I need a database entry for English, even though I'm currently in local => "de". The code is
= link_to tag.name, :controller => "images", :action => t("#{tag.name}")
For the :action I need the English tag name, no matter in which language I'm currently in, but still the German tag.name directly behind the link_to (for the name of the link). So something like:
= link_to tag.name, :controller => "images", :action => t("#{tag.name}", :locale => :en)
But this does not work.
My model Tag is already in two languages, but when I'm currently in "de" locale it always gives me the German name of Tag as action, but indipendent of the current locale I always need the English entry.
class Tag < ActiveRecord::Base
attr_accessible
:name, :id, :content
translates :name, :content
end
It seems to be that you are using Globalize
gem. It has the with_locale()
method which you can use to set an independent locale for specific piece of code.
= link_to tag.name, controller: "images", action: Globalize.with_locale(:en) { tag.name }
Rails I18n has the same method. This is going to work too:
= link_to tag.name, controller: "images", action: I18n.with_locale(:en) { tag.name }