This feature has already been validated, revised and
voted in the Rails tracker
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2637-patch-i18n-look-up-a-translation-with-the-default-locale-when-its-missed-with-another-specific-locale#ticket-2637-11
've added an I18n option to allow to look up a translation with
the default locale when it's missed with another specific
locale.
This is a useful option if you don't want your page will crash
when misses a translation and you don't want to use the
default option in each translation. It's inspired by the
gettext behaviour.
For example, I have this code in an initializer:
I18n.use_default_locale_on_missing_translation = true
I18n.default_locale = :en
And two translation files, en.yml and es.yml:
en:
hello: 'hello'
hello_world: 'hello world'
es:
hello_world: 'hola mundo'
When I execute this code:
I18n.t :hello, :locale => :es
Rails returns hello instead of send an
error