diff options
author | Carl Lerche <carllerche@mac.com> | 2010-04-18 13:02:37 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-04-18 13:02:37 -0700 |
commit | d32a4cbaa5174cc1a73d41a73f55145251c18c84 (patch) | |
tree | 16e3ad82102aa6d290b8941dd69e27b1efaf14f6 /activesupport/lib | |
parent | c16c248912e4ae3b6a64e6acdbf1a1e0dd2feb26 (diff) | |
parent | 8c7e8976e97d96f514e22b04fc1afb9453134076 (diff) | |
download | rails-d32a4cbaa5174cc1a73d41a73f55145251c18c84.tar.gz rails-d32a4cbaa5174cc1a73d41a73f55145251c18c84.tar.bz2 rails-d32a4cbaa5174cc1a73d41a73f55145251c18c84.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/multibyte.rb | 7 | ||||
-rw-r--r-- | activesupport/lib/active_support/railtie.rb | 35 |
2 files changed, 35 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb index 13208c6ee2..42e053d0f8 100644 --- a/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb @@ -49,13 +49,6 @@ class String def is_utf8? ActiveSupport::Multibyte::Chars.consumes?(self) end - - unless '1.8.7 and later'.respond_to?(:chars) - def chars - ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller) - mb_chars - end - end else def mb_chars #:nodoc self diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb index b8d54ff839..0243157e35 100644 --- a/activesupport/lib/active_support/railtie.rb +++ b/activesupport/lib/active_support/railtie.rb @@ -33,6 +33,7 @@ module I18n config.i18n = ActiveSupport::OrderedOptions.new config.i18n.railties_load_path = [] config.i18n.load_path = [] + config.i18n.fallbacks = ActiveSupport::OrderedOptions.new initializer "i18n.initialize" do ActiveSupport.on_load(:i18n) do @@ -53,6 +54,8 @@ module I18n app.config.i18n.load_path.unshift(*value) when :load_path I18n.load_path += value + when :fallbacks + init_fallbacks(value) if value && validate_fallbacks(value) else I18n.send("#{setting}=", value) end @@ -60,5 +63,37 @@ module I18n I18n.reload! end + + class << self + protected + + def init_fallbacks(fallbacks) + include_fallbacks_module + args = case fallbacks + when ActiveSupport::OrderedOptions + [*(fallbacks[:defaults] || []) << fallbacks[:map]].compact + when Hash, Array + Array.wrap(fallbacks) + else # TrueClass + [] + end + I18n.fallbacks = I18n::Locale::Fallbacks.new(*args) + end + + def include_fallbacks_module + I18n.backend.class.send(:include, I18n::Backend::Fallbacks) + end + + def validate_fallbacks(fallbacks) + case fallbacks + when ActiveSupport::OrderedOptions + !fallbacks.empty? + when TrueClass, Array, Hash + true + else + raise "Unexpected fallback type #{fallbacks.inspect}" + end + end + end end end
\ No newline at end of file |