0
我廣泛使用輔助方法time_ago_in_words
,並且它與I18n一樣按預期工作。某些部分/輔助方法的選擇逃逸翻譯
但是在應用程序的某些部分,我只想要默認的英文。
無論如何逃避應用程序的選定方法/領域翻譯?
我廣泛使用輔助方法time_ago_in_words
,並且它與I18n一樣按預期工作。某些部分/輔助方法的選擇逃逸翻譯
但是在應用程序的某些部分,我只想要默認的英文。
無論如何逃避應用程序的選定方法/領域翻譯?
無論全局配置如何,您都可以使用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
。