diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-08 21:31:06 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-08 22:02:49 -0800 |
commit | 7ad461b44dabb586fbad190493ac4ecd96104597 (patch) | |
tree | 2f89687473b4c4254dda032054647fdaa2279d7f /activesupport/lib/active_support | |
parent | c44fb4ced5cbe61adb12f3431db05afa492bd176 (diff) | |
download | rails-7ad461b44dabb586fbad190493ac4ecd96104597.tar.gz rails-7ad461b44dabb586fbad190493ac4ecd96104597.tar.bz2 rails-7ad461b44dabb586fbad190493ac4ecd96104597.zip |
Ruby 1.9.2: avoid Array#to_s and Array(nil)
Diffstat (limited to 'activesupport/lib/active_support')
-rwxr-xr-x | activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb index 1b49debc05..7487b96b8c 100755 --- a/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +++ b/activesupport/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb @@ -195,10 +195,19 @@ module I18n # Merges the given locale, key and scope into a single array of keys. # Splits keys that contain dots into multiple keys. Makes sure all # keys are Symbols. - def normalize_translation_keys(locale, key, scope) - keys = [locale] + Array(scope) + [key] - keys = keys.map { |k| k.to_s.split(/\./) } - keys.flatten.map { |k| k.to_sym } + def normalize_translation_keys(*keys) + normalized = [] + keys.each do |key| + case key + when Array + normalized.concat normalize_translation_keys(*key) + when nil + # skip + else + normalized.concat key.to_s.split('.').map { |sub| sub.to_sym } + end + end + normalized end end end |