From e1a2f42ec57cf5cae2ab8981e122dd889a1ba70f Mon Sep 17 00:00:00 2001 From: Samuel Xavier Date: Fri, 26 May 2023 15:51:17 -0300 Subject: [PATCH 1/4] es_ES corrections for euros and "500" --- currency2text/ctt_languages/es_ES/__init__.py | 2 ++ currency2text/ctt_languages/es_ES/currencies/eur.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/currency2text/ctt_languages/es_ES/__init__.py b/currency2text/ctt_languages/es_ES/__init__.py index e307881..4f61afc 100644 --- a/currency2text/ctt_languages/es_ES/__init__.py +++ b/currency2text/ctt_languages/es_ES/__init__.py @@ -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] diff --git a/currency2text/ctt_languages/es_ES/currencies/eur.py b/currency2text/ctt_languages/es_ES/currencies/eur.py index c8b1f5b..e5818d2 100644 --- a/currency2text/ctt_languages/es_ES/currencies/eur.py +++ b/currency2text/ctt_languages/es_ES/currencies/eur.py @@ -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' From d22df1c4dcdbe7d51c67883d102022e6fbde8088 Mon Sep 17 00:00:00 2001 From: Samuel Xavier Date: Tue, 30 May 2023 20:19:54 -0300 Subject: [PATCH 2/4] Added portguese support for currency2text --- currency2text/ctt_languages/pt_BR/__init__.py | 100 ++++++++++++++++++ .../pt_BR/currencies/__init__.py | 3 + .../ctt_languages/pt_BR/currencies/eur.py | 19 ++++ .../ctt_languages/pt_BR/currencies/mxn.py | 19 ++++ .../ctt_languages/pt_BR/currencies/usd.py | 19 ++++ 5 files changed, 160 insertions(+) create mode 100644 currency2text/ctt_languages/pt_BR/__init__.py create mode 100644 currency2text/ctt_languages/pt_BR/currencies/__init__.py create mode 100644 currency2text/ctt_languages/pt_BR/currencies/eur.py create mode 100644 currency2text/ctt_languages/pt_BR/currencies/mxn.py create mode 100644 currency2text/ctt_languages/pt_BR/currencies/usd.py diff --git a/currency2text/ctt_languages/pt_BR/__init__.py b/currency2text/ctt_languages/pt_BR/__init__.py new file mode 100644 index 0000000..b85a138 --- /dev/null +++ b/currency2text/ctt_languages/pt_BR/__init__.py @@ -0,0 +1,100 @@ +#!/usr/bin/python +# -*- coding: utf8 -*- +# pt_BR +# Portuguese language support assembled from contributions provided by: +# * samuelpx - https://github.com/samuelpx [samuelxpp@gmail.com] +################################################################################ + +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() diff --git a/currency2text/ctt_languages/pt_BR/currencies/__init__.py b/currency2text/ctt_languages/pt_BR/currencies/__init__.py new file mode 100644 index 0000000..a5ef765 --- /dev/null +++ b/currency2text/ctt_languages/pt_BR/currencies/__init__.py @@ -0,0 +1,3 @@ +#!/usr/bin/python +# -*- coding: utf8 -*- +# Please do not edit this file! diff --git a/currency2text/ctt_languages/pt_BR/currencies/eur.py b/currency2text/ctt_languages/pt_BR/currencies/eur.py new file mode 100644 index 0000000..160e44b --- /dev/null +++ b/currency2text/ctt_languages/pt_BR/currencies/eur.py @@ -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'es_ES' + 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() diff --git a/currency2text/ctt_languages/pt_BR/currencies/mxn.py b/currency2text/ctt_languages/pt_BR/currencies/mxn.py new file mode 100644 index 0000000..2511e6a --- /dev/null +++ b/currency2text/ctt_languages/pt_BR/currencies/mxn.py @@ -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'es_ES' + 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() diff --git a/currency2text/ctt_languages/pt_BR/currencies/usd.py b/currency2text/ctt_languages/pt_BR/currencies/usd.py new file mode 100644 index 0000000..e109b98 --- /dev/null +++ b/currency2text/ctt_languages/pt_BR/currencies/usd.py @@ -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'es_ES' + 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() From 05b8c715b2c5ceaacd7564cc9a49722d7af8e2d1 Mon Sep 17 00:00:00 2001 From: Samuel Xavier Date: Tue, 30 May 2023 20:55:58 -0300 Subject: [PATCH 3/4] Implementing pt_BR --- currency2text/ctt_languages/pt_BR/currencies/eur.py | 2 +- currency2text/ctt_languages/pt_BR/currencies/mxn.py | 2 +- currency2text/ctt_languages/pt_BR/currencies/usd.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/currency2text/ctt_languages/pt_BR/currencies/eur.py b/currency2text/ctt_languages/pt_BR/currencies/eur.py index 160e44b..4a1d136 100644 --- a/currency2text/ctt_languages/pt_BR/currencies/eur.py +++ b/currency2text/ctt_languages/pt_BR/currencies/eur.py @@ -5,7 +5,7 @@ class eur(ctt_currency): def _init_currency(self): - self.language = u'es_ES' + self.language = u'pt_BR' self.code = u'EUR' self.fractions = 100 self.cur_singular = u' euro' diff --git a/currency2text/ctt_languages/pt_BR/currencies/mxn.py b/currency2text/ctt_languages/pt_BR/currencies/mxn.py index 2511e6a..e0ee689 100644 --- a/currency2text/ctt_languages/pt_BR/currencies/mxn.py +++ b/currency2text/ctt_languages/pt_BR/currencies/mxn.py @@ -5,7 +5,7 @@ class mxn(ctt_currency): def _init_currency(self): - self.language = u'es_ES' + self.language = u'pt_BR' self.code = u'MXN' self.fractions = 100 self.cur_singular = u' peso' diff --git a/currency2text/ctt_languages/pt_BR/currencies/usd.py b/currency2text/ctt_languages/pt_BR/currencies/usd.py index e109b98..f6b2bc3 100644 --- a/currency2text/ctt_languages/pt_BR/currencies/usd.py +++ b/currency2text/ctt_languages/pt_BR/currencies/usd.py @@ -5,7 +5,7 @@ class usd(ctt_currency): def _init_currency(self): - self.language = u'es_ES' + self.language = u'pt_BR' self.code = u'USD' self.fractions = 100 self.cur_singular = u' dólar' From 4c4cd52624cfd46316b8e1eee5c36d8931218bc9 Mon Sep 17 00:00:00 2001 From: Samuel Xavier Date: Tue, 30 May 2023 21:17:42 -0300 Subject: [PATCH 4/4] Minor corrections --- currency2text/ctt_languages/pt_BR/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/currency2text/ctt_languages/pt_BR/__init__.py b/currency2text/ctt_languages/pt_BR/__init__.py index b85a138..b96c08b 100644 --- a/currency2text/ctt_languages/pt_BR/__init__.py +++ b/currency2text/ctt_languages/pt_BR/__init__.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf8 -*- # pt_BR +################################################################################ # Portuguese language support assembled from contributions provided by: # * samuelpx - https://github.com/samuelpx [samuelxpp@gmail.com] ################################################################################