Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full support for Brazilian Portuguese (#139)
- Loading branch information
Showing
29 changed files
with
702 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
pt-BR: | ||
numbers: | ||
union: e | ||
union_separator: e | ||
integral: | ||
one: inteiro | ||
other: inteiros | ||
ones: | ||
male: [zero, um, dois, três, quatro, cinco, seis, sete, oito, nove] | ||
female: [zero, uma, duas, três, quatro, cinco, seis, sete, oito, nove] | ||
ones_twenties: [zero, um, dois, três, quatro, cinco, seis, sete, oito, nove] | ||
one: um | ||
teens: [dez, onze, doze, treze, quatorze, quinze, dezesseis, dezessete, dezoito, dezenove] | ||
tens: [zero, dez, vinte, trinta, quarenta, cinquenta, sessenta, setenta, oitenta, noventa] | ||
hundreds: | ||
male: [cento, duzentos, trezentos, quatrocentos, quinhentos, seiscentos, setecentos, oitocentos, novecentos] | ||
female: [cento, duzentas, trezentas, quatrocentas, quinhentas, seiscentas, setecentas, oitocentas, novecentas] | ||
one_hundred: cem | ||
mega: [_, mil, milhão, bilhão, trilhão, quadrilhão, quintilhão, sextilhão, septilhão, octilhão, nonilhão, decilhão] | ||
megas: [_, mil, milhões, bilhões, trilhões, quadrilhões, quintilhões, sextilhões, septilhões, octilhões, nonilhões, decilhões] | ||
ordinal: | ||
ones: | ||
male: [zero, primeiro, segundo, terceiro, quarto, quinto, sexto, sétimo, oitavo, nono] | ||
female: [zera, primeira, segunda, terceira, quarta, quinta, sexta, sétima, oitava, nona] | ||
tens: | ||
male: [_, décimo, vigésimo, trigésimo, quadragésimo, quinquagésimo, sexagésimo, septuagésimo, octogésimo, nonagésimo] | ||
female: [_, décima, vigésima, trigésima, quadragésima, quinquagésima, sexagésima, septuagésima, octogésima, nonagésima] | ||
hundreds: | ||
male: [centésimo, ducentésimo, trecentésimo, quadringentésimo, quingentésimo, sexcentésimo, septingentésimo, octingentésimo, noningentésimo] | ||
female: [centésima, ducentésima, trecentésima, quadringentésima, quingentésima, sexcentésima, septingentésima, octingentésima, noningentésima] | ||
mega: | ||
male: [_, milésimo, milionésimo, bilionésimo, trilionésimo, quadrilionésimo, sextilionésimo, septilionésimo, octilionésimo, nonilionésimo] | ||
female: [_, milésima, milionésima, bilionésima, trilionésima, quadrilionésima, sextilionésima, septilionésima, octilionésima, nonilionésima] | ||
micro: [_, tenths, hundredths, thousandths, millionths, billionths, trillionths, quadrillionths, quintillionths, sextillionths, septillionths, octillionths, nonillionths, decillionths, undecillionths, duodecillionths, tredecillionths, quattuordecillionths] | ||
micro_prefix: | ||
tens: | ||
one: décimo | ||
other: décimos | ||
hundreds: | ||
one: centésimo | ||
other: centésimos | ||
tenths: | ||
one: décimo | ||
other: décimos | ||
hundredths: | ||
one: centésimo | ||
other: centésimos | ||
thousandths: | ||
one: milésimo | ||
other: milésimos | ||
millionths: | ||
one: milionésimo | ||
other: milionésimos | ||
billionths: | ||
one: bilionésimo | ||
other: bilionésimos | ||
trillionths: | ||
one: trilionésimo | ||
other: trilionésimo | ||
quadrillionths: | ||
one: quadrilionésimo | ||
other: quadrilionésimos | ||
quintillionths: | ||
one: quintilionésimo | ||
other: quintilionésimos | ||
sextillionths: | ||
one: sextilionésimo | ||
other: sextilionésimos | ||
septillionths: | ||
one: septilionésimo | ||
other: septilionésimos | ||
octillionths: | ||
one: octilionésimo | ||
other: octilionésimos | ||
nonillionths: | ||
one: nonilionésimo | ||
other: nonilionésimos | ||
decillionths: | ||
one: decilionésimo | ||
other: decilionésimos | ||
undecillionths: | ||
one: undecilionésimo | ||
other: undecilionésimos | ||
duodecillion: | ||
one: duodecilionésimo | ||
other: duodecilionésimos | ||
tredecillion: | ||
one: trecentilionésimo | ||
other: trecentilionésimos | ||
quattuordecillion: | ||
one: quadringentilionésimo | ||
other: quadringentilionésimos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Hash[ | ||
NumbersAndWords::I18n::Pluralization.languages.map { |language| | ||
[language.to_sym, {:i18n => {:plural => { | ||
:rule => "NumbersAndWords::I18n::Plurals::#{language.titleize}::RULE".constantize | ||
:rule => "NumbersAndWords::I18n::Plurals::#{language.titleize.gsub(/ /, '')}::RULE".constantize | ||
}}}] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module NumbersAndWords | ||
module I18n | ||
module Plurals | ||
module PtBr | ||
RULE = lambda { |n| one_conditions(n) ? :one : :other } | ||
|
||
extend self | ||
|
||
def one_conditions n | ||
n == 1 | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
lib/numbers_and_words/strategies/array_joiner/languages/pt_br.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module ArrayJoiner | ||
module Languages | ||
class PtBr < Base | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
lib/numbers_and_words/strategies/figures_converter/decorators/pt_br.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'numbers_and_words/strategies/figures_converter/decorators/pt_br/base' | ||
require 'numbers_and_words/strategies/figures_converter/decorators/pt_br/integral' | ||
require 'numbers_and_words/strategies/figures_converter/decorators/pt_br/fractional' |
12 changes: 12 additions & 0 deletions
12
lib/numbers_and_words/strategies/figures_converter/decorators/pt_br/base.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Decorators | ||
module PtBr | ||
class Base < Decorators::Base | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
38 changes: 38 additions & 0 deletions
38
lib/numbers_and_words/strategies/figures_converter/decorators/pt_br/fractional.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Decorators | ||
module PtBr | ||
class Fractional < Base | ||
|
||
def run | ||
"#{super} #{fraction_significance}" | ||
end | ||
|
||
private | ||
|
||
def fraction_significance | ||
@strategy.translations.micros full_fraction.fraction_capacity, figures.join.to_i | ||
end | ||
|
||
def full_fraction | ||
(0..zero_length).inject(figures.clone) { |result, el| result.unshift 0 }.to_figures | ||
end | ||
|
||
def figures | ||
@strategy.figures.reverse | ||
end | ||
|
||
def zero_length | ||
fraction_length - figures.length | ||
end | ||
|
||
def fraction_length | ||
@options[:fractional][:length].to_i | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
29 changes: 29 additions & 0 deletions
29
lib/numbers_and_words/strategies/figures_converter/decorators/pt_br/integral.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module NumbersAndWords | ||
module Strategies | ||
module FiguresConverter | ||
module Decorators | ||
module PtBr | ||
class Integral < Base | ||
def run | ||
"#{super}#{integral_significance}" | ||
end | ||
|
||
private | ||
|
||
def integral_significance | ||
" #{@strategy.translations.integral quantity}" if @options[:remove_zero].nil? | ||
end | ||
|
||
def quantity | ||
figures.reverse.join.to_i | ||
end | ||
|
||
def figures | ||
@strategy.language.figures | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.