#26 new
calavera

I18n, look up a translation with the default locale when it's missed with another specific locale

Reported by calavera | May 13th, 2009 @ 10:20 PM

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'</code>



When I execute this code:

  I18n.t :hello, :locale => :es

Rails returns hello instead of send an error

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Repository for collecting Locale data for Ruby on Rails I18n as well as other interesting, Rails related I18n stuff

People watching this ticket

Attachments

Pages