Skip to content

Commit

Permalink
Merge pull request #85 from jlduran/patch-1
Browse files Browse the repository at this point in the history
Minor orthographic typo
  • Loading branch information
miks committed Oct 22, 2013
2 parents e127045 + 952fc2f commit 5015414
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Számok betűvel írva az I18n könyvtár segítségével.

[11, 22, 133].to_words
=> ["eleven", "twenty-two", "one hundred thirty-three"]
=> ["once", "veintidos", "ciento treinta y tres"]
=> ["once", "veintidós", "ciento treinta y tres"]
=> ["одиннадцать", "двадцать два", "сто тридцать три"]
=> ["onze", "vingt-deux", "cent trente-trois"]
=> ["одинадцять", "двадцять два", "сто тридцять три"]
Expand Down
3 changes: 2 additions & 1 deletion lib/numbers_and_words/i18n/locales/numbers.es.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
es:
numbers:
ones: [cero, uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve]
ones_twenties: [cero, uno, dós, trés, cuatro, cinco, séis, siete, ocho, nueve]
one: un

teens: [diez, once, doce, trece, catorce, quince, dieciseis, diecisiete, dieciocho, diecinueve]
teens: [diez, once, doce, trece, catorce, quince, dieciséis, diecisiete, dieciocho, diecinueve]
tens: [cero, diez, veinti, treinta, cuarenta, cincuenta, sesenta, setenta, ochenta, noventa]
twenty: veinte

Expand Down
19 changes: 14 additions & 5 deletions lib/numbers_and_words/strategies/figures_converter/languages/es.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ def capacity_iteration
words.push megs(capacity_words) unless capacity_words.empty?

if 0 < @current_capacity
# eg 1000000 should be "un millon" not "uno millon"
# eg 1000000 should be "un millón" not "uno millón"
# 501000 should be "quinientos un mil" not "quinientos uno mil"
# so we replace "uno" with "un" throughout
# 1000 should be "mil" not "uno mil"
# so we replace "uno" with "un" throughout or delete it if that is the case

capacity_words = capacity_words.map{|word|
word.gsub( @translations.ones(1), @translations.one )
}
capacity_words = capacity_words.map { |word|
word.gsub(@translations.ones(1), @translations.one) unless is_a_thousand? and is_a_one?
}.compact
end

words + capacity_words
end

def is_a_one?
[translations.ones(1)] == words_in_capacity(@current_capacity)
end

def is_a_thousand?
FiguresArray::THOUSAND_CAPACITY == @current_capacity
end

def hundreds
super({:is_hundred => (figures[1,2] == [0,1] && simple_number_to_words.empty?)})
end
Expand Down
7 changes: 6 additions & 1 deletion lib/numbers_and_words/translations/es.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ def ones number, options = {}
t(:ones)[number]
end

def ones_twenties number, options = {}
t(:ones_twenties)[number]
end

def tens numbers, options = {}
options[:alone] = true if options[:alone].nil?
(numbers == TENS_CASE && options[:alone]) ? t(:twenty) : super(numbers)
end

def tens_with_ones numbers, options = {}
inter = numbers[1] == TENS_CASE ? "" : " y "
[tens(numbers[1], :alone => false), ones(numbers[0])].join inter
ones_number = numbers[1] == TENS_CASE ? ones_twenties(numbers[0]) : ones(numbers[0])
[tens(numbers[1], :alone => false), ones_number].join inter
end

def hundreds number, options = {}
Expand Down
6 changes: 5 additions & 1 deletion spec/numbers_and_words/integer/fixture_examples/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ to_words:
teens:
10: diez
11: once
16: dieciséis
19: diecinueve
20: veinte
21: veintiuno
22: veintidós
23: veintitrés
26: veintiséis
80: ochenta
90: noventa
99: noventa y nueve
Expand All @@ -24,7 +28,7 @@ to_words:
990: novecientos noventa
999: novecientos noventa y nueve
thousands:
1000: un mil
1000: mil
2000: dos mil
4000: cuatro mil
5000: cinco mil
Expand Down

0 comments on commit 5015414

Please sign in to comment.