Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#4428

(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?').

Reported by Sven Fuchs · April 17th, 2010 @ 01:26 PM

State: resolved
Milestone: 3.0.2
Assigned to: nobody
Importance: Low

Activity

  1. Repository
    Repository
    • State changed from new to resolved

    (from [9a3a4d6aefa7e2ca94340754eb5541bea1783de0]) Make i18n fallbacks configurable and fallback to the default locale by default in production [#4428 Add a config.i18n.fallback setting and enable fallbacks in environment/produc... state:resolved]

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

    config.fallbacks = true

    config.fallbacks.map = { :ca => :es }
    config.fallbacks.defaults = [:'es-ES', :es]

    config.fallbacks = [:'es-ES', :es]

    config.fallbacks = { :ca => :es }

    config.fallbacks = [:'es-ES', :es, { :ca => :es }]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com
    http://github.com/rails/rails/commit/9a3a4d6aefa7e2ca94340754eb5541...

    April 17th, 2010 @ 07:29 PM

  2. Aditya Sanghi
    Aditya Sanghi
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 12th, 2010 @ 10:16 AM

  3. Jeremy Kemper
  4. bingbing