Skip to content

Commit

Permalink
Remove TODO, add more specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
KL-7 committed Oct 9, 2014
1 parent 42bb8cb commit a676c51
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/twitter_cldr/data_readers/number_data_reader.rb
Expand Up @@ -133,7 +133,6 @@ def pattern_for_number(pattern, number, decimal)
pattern_sample = range_pattern.values.first

if pattern_sample != 0
# TODO: if the pattern is missing for the pluralization rule, do we raise an exception or fall back to 'pattern'?
range_pattern.fetch(pluralization_rule(number, pattern_sample, decimal))
else
0
Expand All @@ -152,7 +151,9 @@ def truncate_number(number, pattern)

def pluralization_rule(number, pattern, decimal)
truncated_number = truncate_number(number, pattern)
truncated_number = truncated_number.to_i if decimal # decimal and fractional numbers might have different pluralization
# decimal and fractional numbers might have different pluralization,
# so it's important to convert to integer if we want a decimal result
truncated_number = truncated_number.to_i if decimal
TwitterCldr::Formatters::Plurals::Rules.rule_for(truncated_number, locale)
end

Expand Down
Expand Up @@ -81,12 +81,19 @@ def format_number(number, options = {})
expect(format_number(1123, :precision => 3)).to match_normalized("1,123 тысячи")
end

# TODO: requires pluralization from CLDR 26
xit 'works with :few in Russian' do
it 'works with :few in Russian' do
expect(format_number(7123, :precision => 3)).to match_normalized("7,123 тысячи")
expect(format_number(7123)).to match_normalized("7 тысяч") # different pluralization when precision is 0
end

context 'with Korean locale' do
let(:locale) { :ko }

xit 'works for Korean' do
expect(format_number(1_000_000)).to match_normalized("100만") # not "1 million"
end
end

xit 'works when pattern is 0 (e.g., for Japanese)'
end
end

0 comments on commit a676c51

Please sign in to comment.