Skip to content

Commit

Permalink
#42. Add Spanish language. (experimental)
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'remotes/highercomve/master' into feature/add_spanish_language
  • Loading branch information
kslazarev committed Feb 7, 2013
2 parents 3ab40b3 + 68367b7 commit 890d203
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 1 deletion.
42 changes: 42 additions & 0 deletions lib/numbers_and_words/i18n/locales/numbers.es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
es:
numbers:
ones: [cero, uno, dos, tres, cuatro, cinco, seis, siete, ocho, nueve]
teens: [diez, once, doce, trece, catorce, quince, dieciséis, diecisiete, dieciocho, diecinueve]
tens: [0, 10, veinte, teinta, cuarenta, cincuenta, sesenta, setenta, ochenta, noventa]
mega: [ones, thousands, millions, billions, trillions, quadrillions, quintillion, sextillions, septillions, octillions, nonillions, decillions]
hundreds:
one: cien
many: ciento
thousands:
one: mil
many: mil
millions:
one: millon
many: millones
billions:
one: millardo
many: millardos
trillions:
one: billardo
many: billardos
quadrillions:
one: billardo
many: billardos
quintillions:
one: trillion
many: trillions
sextillions:
one: trilliard
many: trilliards
septillions:
one: quadrillion
many: quadrillions
octillions:
one: quadrilliard
many: quadrilliards
nonillions:
one: quintillion
many: quintillions
decillions:
one: quintilliard
many: quintilliards
1 change: 1 addition & 0 deletions lib/numbers_and_words/i18n/pluralization.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'numbers_and_words/i18n/plurals/ru'
require 'numbers_and_words/i18n/plurals/ua'
require 'numbers_and_words/i18n/plurals/fr'
require 'numbers_and_words/i18n/plurals/es'

module NumbersAndWords
module I18n
Expand Down
15 changes: 15 additions & 0 deletions lib/numbers_and_words/i18n/plurals/es.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module NumbersAndWords
module I18n
module Plurals
module Es
RULE = lambda { |n| one_conditions(n) ? :one : :many }

extend self

def one_conditions n
n % 10 == 1 && n % 100 != 11
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/numbers_and_words/strategies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
require 'numbers_and_words/strategies/nl'
require 'numbers_and_words/strategies/it'
require 'numbers_and_words/strategies/hu'
require 'numbers_and_words/strategies/se'
require 'numbers_and_words/strategies/se'
require 'numbers_and_words/strategies/es'
8 changes: 8 additions & 0 deletions lib/numbers_and_words/strategies/es.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module NumbersAndWords
module Strategies
class Es < Base
include Families::Latin
include NumbersAndWords::TranslationsHelpers::Es
end
end
end
1 change: 1 addition & 0 deletions lib/numbers_and_words/translations_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
require 'numbers_and_words/translations_helpers/it'
require 'numbers_and_words/translations_helpers/hu'
require 'numbers_and_words/translations_helpers/se'
require 'numbers_and_words/translations_helpers/es'
2 changes: 2 additions & 0 deletions lib/numbers_and_words/translations_helpers/en.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module En
def translation_tens_with_ones numbers
super numbers, '-'
end


end
end
end
13 changes: 13 additions & 0 deletions lib/numbers_and_words/translations_helpers/es.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module NumbersAndWords
module TranslationsHelpers
module Es
include NumbersAndWords::TranslationsHelpers::Base
include NumbersAndWords::TranslationsHelpers::Families::Latin

def translation_tens_with_ones numbers
super numbers, ' y '
end

end
end
end

0 comments on commit 890d203

Please sign in to comment.