mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix some warnings in i18n lib
This commit is contained in:
parent
d84d99a8f7
commit
8c2e839e5a
2 changed files with 5 additions and 5 deletions
|
@ -53,7 +53,7 @@ module I18n
|
||||||
# storage. Decoupled for backends like a db backend that persist their
|
# storage. Decoupled for backends like a db backend that persist their
|
||||||
# translations, so the backend can decide whether/when to yield or not.
|
# translations, so the backend can decide whether/when to yield or not.
|
||||||
def populate(&block)
|
def populate(&block)
|
||||||
backend.populate &block
|
backend.populate(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Stores translations for the given locale in the backend.
|
# Stores translations for the given locale in the backend.
|
||||||
|
@ -173,8 +173,8 @@ module I18n
|
||||||
# keys are Symbols.
|
# keys are Symbols.
|
||||||
def normalize_translation_keys(locale, key, scope)
|
def normalize_translation_keys(locale, key, scope)
|
||||||
keys = [locale] + Array(scope) + [key]
|
keys = [locale] + Array(scope) + [key]
|
||||||
keys = keys.map{|key| key.to_s.split(/\./) }
|
keys = keys.map{|k| k.to_s.split(/\./) }
|
||||||
keys.flatten.map{|key| key.to_sym}
|
keys.flatten.map{|k| k.to_sym}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ module I18n
|
||||||
|
|
||||||
def translate(locale, key, options = {})
|
def translate(locale, key, options = {})
|
||||||
raise InvalidLocale.new(locale) if locale.nil?
|
raise InvalidLocale.new(locale) if locale.nil?
|
||||||
return key.map{|key| translate locale, key, options } if key.is_a? Array
|
return key.map{|k| translate locale, k, options } if key.is_a? Array
|
||||||
|
|
||||||
reserved = :scope, :default
|
reserved = :scope, :default
|
||||||
count, scope, default = options.values_at(:count, *reserved)
|
count, scope, default = options.values_at(:count, *reserved)
|
||||||
|
@ -66,7 +66,7 @@ module I18n
|
||||||
def lookup(locale, key, scope = [])
|
def lookup(locale, key, scope = [])
|
||||||
return unless key
|
return unless key
|
||||||
keys = I18n.send :normalize_translation_keys, locale, key, scope
|
keys = I18n.send :normalize_translation_keys, locale, key, scope
|
||||||
keys.inject(@@translations){|result, key| result[key.to_sym] or return nil }
|
keys.inject(@@translations){|result, k| result[k.to_sym] or return nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Evaluates a default translation.
|
# Evaluates a default translation.
|
||||||
|
|
Loading…
Reference in a new issue