This project is archived and is in readonly mode.

#4428 ✓resolved
Sven Fuchs

Add a config.i18n.fallback setting and enable fallbacks in environment/production.rb

Reported by Sven Fuchs | April 17th, 2010 @ 01:26 PM | in 3.0.2

(As discussed with Pratik ...)

The attached patch adds a config.i18n.fallbacks setting and test cases for the I18n::Railtie. It also enables fallbacks by default in environment/production.rb

Allows to configure locale fallbacks through config.i18n.fallbacks. The default setting config.i18n.fallbacks = true in production.rb will make I18n.t lookup fall back to the I18n.default_locale if a translation could not be found for the current or given locale.

# USAGE

# do nothing in config (i.e. remove the line in environment/production.rb)
# => local fallbacks won't be used

# set to true
config.fallbacks = true
# => uses I18n::Fallbacks.new
# always falls back to the I18n.default_locale

# use the OrderedOptions
config.fallbacks.map = { :ca => :es }
config.fallbacks.defaults = [:'es-ES', :es]
# => uses I18n::Fallbacks.new(:'es-ES', :es, :ca => :es), see below

# SHORTCUTS

# set to an Array of defaults
config.fallbacks = [:'es-ES', :es]
# => uses I18n::Fallbacks.new(:'es-ES', :es)
# always finally falls back to the I18n.default_locale, additionally always falls back through es-ES and es

# set to a Hash of mappings
config.fallbacks = { :ca => :es }
# => uses I18n::Fallbacks.new(:'es-ES', :es)
# always finally falls back to the I18n.default_locale, additionally falls back from cs to es

# default Array and mappings Hash can be mixed
config.fallbacks = [:'es-ES', :es, { :ca => :es }]
# => uses I18n::Fallbacks.new(:'es-ES', :es, :ca => :es)

The added railties/i18n_railtie_test passes on 1.8.7 and 1.9.1, although I get an outright segfault when trying to run the entire Railties test suite on 1.9.1. Also, on 1.8.7 I got a ton of failures in ActionPack tests although I don' think they are related to my changes in any way (TypeError: can't modify frozen object, in rack/mount/route.rb:91:in significant_params?').

Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages