提交 7ad461b4 编写于 作者: J Jeremy Kemper

Ruby 1.9.2: avoid Array#to_s and Array(nil)

上级 c44fb4ce
......@@ -195,10 +195,19 @@ def default_exception_handler(exception, locale, key, options)
# 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册