Skip to content

Commit

Permalink
get rid of warnings in 1.9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Nov 17, 2010
1 parent e270d72 commit 05bfa65
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions lib/i18n/backend/gettext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def normalize(locale, data)
key, value = normalize_pluralization(locale, key, value) if key.index("\000")

parts = key.split('|').reverse
normalized = parts.inject({}) do |normalized, part|
normalized = { part => normalized.empty? ? value : normalized }
normalized = parts.inject({}) do |_normalized, part|
{ part => _normalized.empty? ? value : _normalized }
end

result.deep_merge!(normalized)
Expand All @@ -62,7 +62,7 @@ def normalize_pluralization(locale, key, value)
raise "invalid number of plurals: #{values.size}, keys: #{keys.inspect}" if values.size != keys.size

result = {}
values.each_with_index { |value, ix| result[keys[ix]] = value }
values.each_with_index { |_value, ix| result[keys[ix]] = _value }
[key, result]
end

Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/locale/fallbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def [](locale)
def map(mappings)
mappings.each do |from, to|
from, to = from.to_sym, Array(to)
to.each do |to|
to.each do |_to|
@map[from] ||= []
@map[from] << to.to_sym
@map[from] << _to.to_sym
end
end
end
Expand All @@ -85,7 +85,7 @@ def map(mappings)
def compute(tags, include_defaults = true)
result = Array(tags).collect do |tag|
tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym }
tags.each { |tag| tags += compute(@map[tag]) if @map[tag] }
tags.each { |_tag| tags += compute(@map[_tag]) if @map[_tag] }
tags
end.flatten
result.push(*defaults) if include_defaults
Expand Down
12 changes: 6 additions & 6 deletions lib/i18n/tests/localization/procs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ module Procs
test "localize: using day names from lambdas" do
setup_time_proc_translations
time = ::Time.utc(2008, 3, 1, 6, 0)
assert_match /Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru)
assert_match /суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru)
assert_match(/Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru))
assert_match(/суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru))
end

test "localize: using month names from lambdas" do
setup_time_proc_translations
time = ::Time.utc(2008, 3, 1, 6, 0)
assert_match /марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru)
assert_match /Март /, I18n.l(time, :format => "%B %Y", :locale => :ru)
assert_match(/марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru))
assert_match(/Март /, I18n.l(time, :format => "%B %Y", :locale => :ru))
end

test "localize: using abbreviated day names from lambdas" do
setup_time_proc_translations
time = ::Time.utc(2008, 3, 1, 6, 0)
assert_match /марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru)
assert_match /март /, I18n.l(time, :format => "%b %Y", :locale => :ru)
assert_match(/марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru))
assert_match(/март /, I18n.l(time, :format => "%b %Y", :locale => :ru))
end

test "localize Date: given a format that resolves to a Proc it calls the Proc with the object" do
Expand Down
2 changes: 1 addition & 1 deletion test/backend/chain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def setup

def backend(translations)
backend = I18n::Backend::Simple.new
translations.each { |locale, translations| backend.store_translations(locale, translations) }
translations.each { |locale, data| backend.store_translations(locale, data) }
backend
end
end
22 changes: 11 additions & 11 deletions test/locale/tag/rfc4646_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class I18nLocaleTagSubtagsTest < Test::Unit::TestCase

def setup
subtags = %w(de Latn DE variant a-ext x-phonebk i-klingon)
@tag = Tag::Rfc4646.new *subtags
@tag = Tag::Rfc4646.new(*subtags)
end

test "returns 'de' as the language subtag in lowercase" do
Expand Down Expand Up @@ -80,32 +80,32 @@ def setup

class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
test "#parent returns 'de-Latn-DE-variant-a-ext-x-phonebk' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk i-klingon))
assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s
end

test "#parent returns 'de-Latn-DE-variant-a-ext' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk'" do
tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk)
tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk))
assert_equal 'de-Latn-DE-variant-a-ext', tag.parent.to_s
end

test "#parent returns 'de-Latn-DE-variant' as the parent of 'de-Latn-DE-variant-a-ext'" do
tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext)
tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext))
assert_equal 'de-Latn-DE-variant', tag.parent.to_s
end

test "#parent returns 'de-Latn-DE' as the parent of 'de-Latn-DE-variant'" do
tag = Tag::Rfc4646.new *%w(de Latn DE variant)
tag = Tag::Rfc4646.new(*%w(de Latn DE variant))
assert_equal 'de-Latn-DE', tag.parent.to_s
end

test "#parent returns 'de-Latn' as the parent of 'de-Latn-DE'" do
tag = Tag::Rfc4646.new *%w(de Latn DE)
tag = Tag::Rfc4646.new(*%w(de Latn DE))
assert_equal 'de-Latn', tag.parent.to_s
end

test "#parent returns 'de' as the parent of 'de-Latn'" do
tag = Tag::Rfc4646.new *%w(de Latn)
tag = Tag::Rfc4646.new(*%w(de Latn))
assert_equal 'de', tag.parent.to_s
end

Expand All @@ -124,8 +124,8 @@ class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
de-Latn-DE
de-Latn
de)
tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
assert_equal parents, tag.self_and_parents.map{|tag| tag.to_s}
tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk i-klingon))
assert_equal parents, tag.self_and_parents.map(&:to_s)
end

test "returns an array of 5 parents for 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
Expand All @@ -136,7 +136,7 @@ class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
de-Latn-DE
de-Latn
de)
tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
assert_equal parents, tag.self_and_parents.map{|tag| tag.to_s}
tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk i-klingon))
assert_equal parents, tag.self_and_parents.map(&:to_s)
end
end

0 comments on commit 05bfa65

Please sign in to comment.