Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es_ES corrections for euros and "500" #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions currency2text/ctt_languages/es_ES/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def wordify(self, chunk, chunknr, gender):
words += self.multi_sng_msc[0]
elif digit1 == '1' and (digit2 != 0 or digit3 != '0'):
words += self.multi_sng_msc[0] + 'to'
elif digit1 == '5':
words += 'quinientos'
else :
if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)]\
+ self.multi_plr_msc[0]
Expand Down
4 changes: 2 additions & 2 deletions currency2text/ctt_languages/es_ES/currencies/eur.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def _init_currency(self):
self.fractions = 100
self.cur_singular = u' euro'
self.cur_plural = u' euros'
self.frc_singular = u' centavo'
self.frc_plural = u' centavos'
self.frc_singular = u' centimo'
self.frc_plural = u' centimos'
# grammatical genders: f - feminine, m - masculine, n -neuter
self.cur_gram_gender = 'm'
self.frc_gram_gender = 'm'
Expand Down
101 changes: 101 additions & 0 deletions currency2text/ctt_languages/pt_BR/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# pt_BR
################################################################################
# Portuguese language support assembled from contributions provided by:
# * samuelpx - https://github.com/samuelpx [[email protected]]
################################################################################

from currency2text.ctt_objects import ctt_language

class pt_BR(ctt_language):
def _init_lang(self):
# language name
self.name = 'pt_BR'
# digits - masculine, singular
self.digits_sng_msc = [u'zero', u'um', u'dois', u'três', u'quatro',
u'cinco', u'seis', u'sete', u'oito', u'nove']

# tens - masculine, singular
self.tens_sng_msc = [u'', u'', u'vinte', u'trinta', u'quarenta',
u'cinquenta', u'sessenta', u'setenta', u'oitenta',
u'noventa']

# teens - masculine
self.teens = [u'dez', u'onze', u'doze', u'treze', u'quatorze',
u'quinze', u'dezesseis', u'dezessete', u'dezoito',
u'dezenove']

# multiplier - masculine, singular
self.multi_sng_msc = [u'cem', u' mil', u' milhão', u' bilhão']

# multiplier - masculine, plural
self.multi_plr_msc = [u'cento', u' mil', u' milhões', u' bilhões']

# next line is needed for correct loading of currencies
from . import currencies
return currencies


def wordify(self, chunk, chunknr, gender):
if gender == 'm':
number = self.digits_sng_msc
elif gender == 'f':
number = self.digits_sng_fem
elif gender == 'n':
number = self.digits_sng_neu
words = u''
digit1 = u''
digit2 = u''
digit3 = u''
chunklength = len(chunk)
# placing digits in right places
if chunklength == 1:
digit3 = chunk[0 : 1]
if chunklength == 2:
digit2 = chunk[0 : 1]
digit3 = chunk[1 : 2]
if chunklength == 3:
digit1 = chunk[0 : 1]
digit2 = chunk[1 : 2]
digit3 = chunk[-1]
# processing zero
if chunklength == 1 and digit3 == '0' :
return number[0]
# processing hundreds
if chunklength == 3 :
if digit1 == '1' and digit2 == '0' and digit3 == '0':
words += self.multi_sng_msc[0]
else :
if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)]\
+ self.multi_plr_msc[0]
# processing tens
if chunklength > 1:
spacer = ''
if len(words) > 0 : spacer = u' '
if digit2 == '1':
words += spacer + self.teens[int(digit3)]
else:
if int(digit2) > 1 and int(digit2) > 0:
words += spacer + self.tens_sng_msc[int(digit2)]
if int(digit3) > 0:
words += u' y'

# processing ones
if chunklength > 0 and digit2 != '1' :
spacer = ''
if len(words) > 0: spacer = u' '
if int(digit3) > 0:
words += spacer + number[int(digit3)]
# end processing
if len(words) > 0 :
if digit3 == '1' and chunknr > 0:
return words + self.multi_sng_msc[chunknr]
elif digit3 != '1' and chunknr > 0:
return words + self.multi_plr_msc[chunknr]
else:
return words
else:
return ''

pt_BR()
3 changes: 3 additions & 0 deletions currency2text/ctt_languages/pt_BR/currencies/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/python
# -*- coding: utf8 -*-
# Please do not edit this file!
19 changes: 19 additions & 0 deletions currency2text/ctt_languages/pt_BR/currencies/eur.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/python
# -*- coding: utf8 -*-

from currency2text.ctt_objects import ctt_currency

class eur(ctt_currency):
def _init_currency(self):
self.language = u'pt_BR'
self.code = u'EUR'
self.fractions = 100
self.cur_singular = u' euro'
self.cur_plural = u' euros'
self.frc_singular = u' cêntimo'
self.frc_plural = u' cêntimos'
# grammatical genders: f - feminine, m - masculine, n -neuter
self.cur_gram_gender = 'm'
self.frc_gram_gender = 'm'

eur()
19 changes: 19 additions & 0 deletions currency2text/ctt_languages/pt_BR/currencies/mxn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/python
# -*- coding: utf8 -*-

from currency2text.ctt_objects import ctt_currency

class mxn(ctt_currency):
def _init_currency(self):
self.language = u'pt_BR'
self.code = u'MXN'
self.fractions = 100
self.cur_singular = u' peso'
self.cur_plural = u' pesos'
self.frc_singular = u' centavo'
self.frc_plural = u' centavos'
# grammatical genders: f - feminine, m - masculine, n -neuter
self.cur_gram_gender = 'm'
self.frc_gram_gender = 'm'

mxn()
19 changes: 19 additions & 0 deletions currency2text/ctt_languages/pt_BR/currencies/usd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/pythonAméricanos
# -*- coding: utf8 -*-

from currency2text.ctt_objects import ctt_currency

class usd(ctt_currency):
def _init_currency(self):
self.language = u'pt_BR'
self.code = u'USD'
self.fractions = 100
self.cur_singular = u' dólar'
self.cur_plural = u' dólares'
self.frc_singular = u' centavo'
self.frc_plural = u' centavos'
# grammatical genders: f - feminine, m - masculine, n -neuter
self.cur_gram_gender = 'm'
self.frc_gram_gender = 'm'

usd()