This project is archived and is in readonly mode.
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
-
Repository April 17th, 2010 @ 07:29 PM
- State changed from new to resolved
(from [9a3a4d6aefa7e2ca94340754eb5541bea1783de0]) Make i18n fallbacks configurable and fallback to the default locale by default in production [#4428 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... -
Aditya Sanghi October 12th, 2010 @ 10:16 AM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
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
- 4428 Add a config.i18n.fallback setting and enable fallbacks in environment/production.rb (from [9a3a4d6aefa7e2ca94340754eb5541bea1783de0]) Make i1...
- 5785 config.i18n.fallbacks away from default locale seems to break unit tests The config.i18n.fallbacks = {:lv => :en} was based on the...