Skip to content

Commit

Permalink
Ruby 1.9: silence some warnings for block args shadowing local vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Aug 24, 2008
1 parent 2dd91ba commit abd8792
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def default_exception_handler(exception, locale, key, options)
# keys are Symbols.
def normalize_translation_keys(locale, key, scope)
keys = [locale] + Array(scope) + [key]
keys = keys.map{|key| key.to_s.split(/\./) }
keys.flatten.map{|key| key.to_sym}
keys = keys.map{|k| k.to_s.split(/\./) }
keys.flatten.map{|k| k.to_sym}
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/i18n/backend/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def store_translations(locale, data)

def translate(locale, key, options = {})
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
count, scope, default = options.values_at(:count, *reserved)
Expand Down Expand Up @@ -73,7 +73,7 @@ def localize(locale, object, format = :default)
def lookup(locale, key, scope = [])
return unless key
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

# Evaluates a default translation.
Expand Down Expand Up @@ -146,9 +146,9 @@ def load_file(filename)
type = File.extname(filename).tr('.', '').downcase
raise UnknownFileType.new(type, filename) unless respond_to? :"load_#{type}"
data = send :"load_#{type}", filename # TODO raise a meaningful exception if this does not yield a Hash
data.each do |locale, data|
merge_translations locale, data
end
data.each do |locale, d|
merge_translations locale, d
end
end

# Loads a plain Ruby translations file. eval'ing the file must yield
Expand Down

0 comments on commit abd8792

Please sign in to comment.