2015-10-10 33 views

回答

1

无论全局配置如何,您都可以使用I18n.with_locale方法强制特定语言环境下的代码块。

I18n.with_locale(:en) do 
    time_ago_in_words(...) 
end 

如果您发现自己经常使用此模式,您可以创建一个特定的帮助程序。

def english_time_ago_in_words(*args) 
    I18n.with_locale(:en) do 
    time_ago_in_words(*args) 
    end 
end 

您还可以使用I18n.default_locale,而不是直接引用:en