Merge lp:~chris-ormaza/aeroo/openerp6 into lp:aeroo/openerp6

Proposed by Christopher Ormaza - (Ecuadorenlinea.net)
Status: Needs review
Proposed branch: lp:~chris-ormaza/aeroo/openerp6
Merge into: lp:aeroo/openerp6
Diff against target: 179 lines (+60/-12)
1 file modified
report_aeroo/currency_to_text.py (+60/-12)
To merge this branch: bzr merge lp:~chris-ormaza/aeroo/openerp6
Reviewer Review Type Date Requested Status
sraps (Alistek) Needs Information
Review via email: mp+87157@code.launchpad.net

Description of the change

Add Spanish Support

To post a comment you must log in.
Revision history for this message
sraps (Alistek) (erpsraps) wrote :

Hi, Christopher!

First of all - thanks for the work!
We will implement your localization in Aeroo, still some remarks:
* Do you think that it would be good to use just "es" in supported_language variable, preferably express them in form equal to OpenERP's language list (lv_LV, en_US,...). Even though there would be some dummy language codes, still user would not need to do a conversion on template. So templates would become generic even for languages not directly developed to.

* we will not include this inside Aeroo Reports 1.0, but rather port it to the trunk version with completely redesigned this function. Although technically function in this form performed fair enough, it already has become unmanageable by increasing number of languages present.

Please provide your answer on the es/es_ES question...

BR
Kaspars

review: Needs Information
Revision history for this message
Christopher Ormaza - (Ecuadorenlinea.net) (chris-ormaza) wrote :

Hi, Kaspars!

I think the code should have 'es_ES' too, really I just put 'es' because I thought it would be more generic, but if you are agree, I put the 'es_ES' in the code and re-merge the branch, I don't have problem with this, and thanks for your revision and add for this fantastic work

Regards
Christopher

> Hi, Christopher!
>
> First of all - thanks for the work!
> We will implement your localization in Aeroo, still some remarks:
> * Do you think that it would be good to use just "es" in supported_language
> variable, preferably express them in form equal to OpenERP's language list
> (lv_LV, en_US,...). Even though there would be some dummy language codes,
> still user would not need to do a conversion on template. So templates would
> become generic even for languages not directly developed to.
>
> * we will not include this inside Aeroo Reports 1.0, but rather port it to the
> trunk version with completely redesigned this function. Although technically
> function in this form performed fair enough, it already has become
> unmanageable by increasing number of languages present.
>
> Please provide your answer on the es/es_ES question...
>
> BR
> Kaspars

Unmerged revisions

7. By Christopher Ormaza - (Ecuadorenlinea.net)

Add Spanish Support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'report_aeroo/currency_to_text.py'
2--- report_aeroo/currency_to_text.py 2011-11-15 11:01:45 +0000
3+++ report_aeroo/currency_to_text.py 2011-12-30 18:05:26 +0000
4@@ -4,15 +4,16 @@
5 ###########################################################
6 # Developed by Kaspars Vilkens - Alistek Ltd (c) 2011
7 # pep-8, unicode and doctests by Paul Stevens, paul@nfg.nl, 2010
8+# Spanish Support added by Christopher Ormaza - Ecuadorenlinea.net <chris.ormaza@gmail.com>, 2011
9 #
10 # Supported currencies: LVL, EUR, USD, UAH
11 # Supported sum: 0 ... 999999999999.99
12-# Supported languages: lv_LV, en_US, ru_RU, uk_UA
13+# Supported languages: lv_LV, en_US, ru_RU, uk_UA, es
14 ###########################################################
15 import string
16
17-supported_currency = ['LVL','EUR','USD', 'UAH']
18-supported_language = ['lv_LV','en_US','ru_RU', 'uk_UA']
19+supported_currency = ['LVL', 'EUR', 'USD', 'UAH']
20+supported_language = ['lv_LV', 'en_US', 'ru_RU', 'uk_UA','es']
21
22 def currency_to_text(sum, currency, language):
23 """
24@@ -46,17 +47,17 @@
25 raise Exception('Sum out of bounds: must be from 0 to 999999999999.99')
26 if currency not in supported_currency:
27 raise Exception("""Unsupported or no currency: must be one of (%s)""" % \
28- string.join(supported_currency,','))
29+ string.join(supported_currency, ','))
30 if language not in supported_language:
31 raise Exception("""Unsupported or no language: must be one of (%s)""" % \
32- string.join(supported_language,','))
33+ string.join(supported_language, ','))
34 #--------------for currencies with 100 fractions
35 sum = float(sum)
36 sum = round(sum, 2)
37 # find out digits before floating point - currency
38 sum_cur = int(sum)
39 # find out digits after floating point - fractions
40- sum_frc = int(round((sum - sum_cur) * 100,0))
41+ sum_frc = int(round((sum - sum_cur) * 100, 0))
42 cur_in_words = dtowords(sum_cur, language)
43 #print cur_in_words
44 frc_in_words = dtowords(sum_frc, language)
45@@ -122,6 +123,33 @@
46 frc_in_words += u' santims'
47 elif currency == 'EUR' or currency == 'USD' :
48 frc_in_words += u' cents'
49+
50+ #------------------------------------
51+ if language == 'es' :
52+ if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one
53+ if currency == 'LVL':
54+ cur_in_words += u' Latvian lats'
55+ elif currency == 'EUR':
56+ cur_in_words += u' Euro'
57+ elif currency == 'USD':
58+ cur_in_words += u' Dolar Américano'
59+ else:
60+ if currency == 'LVL':
61+ cur_in_words += u' Latvian lats'
62+ elif currency == 'EUR':
63+ cur_in_words += u' Euros'
64+ elif currency == 'USD':
65+ cur_in_words += u' Dolares Américanos'
66+ if sum_frc == 1 or (str(sum_frc)[-1] == '1' and str(sum_frc)[-2] != '1'): # is the fraction sum one
67+ if currency == 'LVL':
68+ frc_in_words += u' santim'
69+ elif currency == 'EUR' or currency == 'USD':
70+ frc_in_words += u' Centavo'
71+ else:
72+ if currency == 'LVL':
73+ frc_in_words += u' santims'
74+ elif currency == 'EUR' or currency == 'USD' :
75+ frc_in_words += u' Centavos'
76 #------------------------------------
77 if language == 'ru_RU' :
78 if sum_cur == 1 or (str(sum_cur)[-1] == '1' and str(sum_cur)[-2] != '1'): # is the currency sum one
79@@ -282,7 +310,7 @@
80 lengthx = len(str(sum_integers))
81 nrchunks = (lengthx / 3)
82 if nrchunks < (float(lengthx) / 3) :
83- nrchunks+=1
84+ nrchunks += 1
85 inc = 1
86 while inc <= nrchunks:
87 startpos = (lengthx - inc * 3)
88@@ -292,7 +320,7 @@
89 startpos = 0
90 chunk = str(sum_integers)[startpos : startpos + chunklength]
91 #print str(startpos)+' '+str(chunklength)+' '+ chunk
92- wordified = wordify(chunk, inc-1, language)
93+ wordified = wordify(chunk, inc - 1, language)
94 inc += 1
95 spacer = ''
96 if len(diginwords) > 0 :
97@@ -326,6 +354,16 @@
98 daudzums = [u' hundred', u' thousand', u' million', u' billion']
99 daudzumsx = daudzums
100
101+ elif language == 'es':
102+ skaitli = [u'Cero', u'Uno', u'Dos', u'Tres', u'Cuatro', u'Cinco', u'Seis',
103+ u'Siete', u'Ocho', u'Nueve']
104+ skaitlix = [u'Cero', u'Diez', u'Veinte', u'Treinta', u'Cuarenta', u'Cincuenta', u'Sesenta',
105+ u'Setenta', u'Ochenta', u'Noventa']
106+ skaitli_teens = [u'Diez', u'Once', u'Doce', u'Trece', u'Catorce',
107+ u'Quince', u'Diez y Seis', u'Diez y Siete', u'Diez y Ocho', u'Diez y Nueve']
108+ daudzums = [u' Cien', u' Mil', u' Millon', u' Billon']
109+ daudzumsx = daudzums
110+
111 elif language == 'ru_RU':
112 skaitli = [u'ноль', u'один', u'два', u'три', u'четыре', u'пять', u'шесть',
113 u'семь', u'восемь', u'девять']
114@@ -361,8 +399,9 @@
115 digit1 = chunk[0 : 1]
116 digit2 = chunk[1 : 2]
117 digit3 = chunk[-1]
118+
119 # processing zero
120- if chunklength == 1 and digit3 == '0' :
121+ if chunklength == 1 and digit3 == '0' :
122 return skaitli[0]
123 # processing hundreds
124 if chunklength == 3 :
125@@ -371,11 +410,15 @@
126 words += daudzums[0]
127 elif language == 'en_US' :
128 words += skaitli[int(digit1)] + daudzumsx[0]
129+ elif language == 'es' :
130+ words += skaitli[int(digit1)] + daudzumsx[0]
131 else :
132 if language == 'lv_LV' :
133 if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0]
134 elif language == 'en_US' :
135 if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0]
136+ elif language == 'es' :
137+ if int(digit1) > 1 : words += skaitli[int(digit1)] + daudzumsx[0] + u'tos'
138 elif language == 'ru_RU' :
139 if int(digit1) == 2 :
140 words += u'двести'
141@@ -399,7 +442,7 @@
142 spacer = ''
143 if len(words) > 0 : spacer = ' '
144 if digit2 == '1':
145- if language == 'lv_LV' or language == 'en_US' or language == 'ru_RU' or language == 'uk_UA':
146+ if language == 'lv_LV' or language == 'en_US' or language == 'ru_RU' or language == 'uk_UA' or language == 'es':
147 words += spacer + skaitli_teens[int(digit3)]
148 else:
149 if language == 'lv_LV':
150@@ -408,6 +451,11 @@
151 elif language == 'en_US':
152 if int(digit2) > 1 and int(digit2) > 0:
153 words += spacer + skaitlix[int(digit2)] + u'ty'
154+ elif language == 'es':
155+ if int(digit2) > 1 and int(digit2) > 0:
156+ words += spacer + skaitlix[int(digit2)]
157+ if int(digit3) > 0:
158+ words += u' y'
159 elif language == 'ru_RU':
160 if int(digit2) > 1 and int(digit2) < 4:
161 words += spacer + skaitlix[int(digit2)] + u'дцать'
162@@ -430,7 +478,7 @@
163 if chunklength > 0 and digit2 != '1' :
164 spacer = ''
165 if len(words) > 0: spacer = u' '
166- if language == 'lv_LV' or language == 'en_US':
167+ if language == 'lv_LV' or language == 'en_US' or language == 'es':
168 if int(digit3) > 0:
169 words += spacer + skaitli[int(digit3)]
170 elif language == 'ru_RU':
171@@ -456,7 +504,7 @@
172 if digit3 == '1' and chunknr > 0:
173 return words + daudzums[chunknr]
174 elif digit3 != '1' and chunknr > 0:
175- if language == 'lv_LV' or language == 'en_US' :
176+ if language == 'lv_LV' or language == 'en_US' or language == 'es' :
177 return words + daudzumsx[chunknr]
178 elif language == 'ru_RU' :
179 if (int(digit3) == 2 or int(digit3) == 3 or int(digit3) == 4) and digit2 != '1' :