I use the helper method time_ago_in_words
extensively, and it works as expected with I18n.
But in some parts of the application, I just want the default english.
Is there anyway to escape translation on selected methods/areas of an application?
I use the helper method time_ago_in_words
extensively, and it works as expected with I18n.
But in some parts of the application, I just want the default english.
Is there anyway to escape translation on selected methods/areas of an application?
You can use the I18n.with_locale
method to force a block of code under a specific locale regardless the global configuration.
I18n.with_locale(:en) do
time_ago_in_words(...)
end
If you find yourself using this pattern frequently, you can create a specific helper.
def english_time_ago_in_words(*args)
I18n.with_locale(:en) do
time_ago_in_words(*args)
end
end
You can also use I18n.default_locale
instead of referencing :en
directly.