~aeroo-team/aeroo/openerp6.1.x

« back to all changes in this revision

Viewing changes to report_aeroo/ctt_languages/es_ES/__init__.py

  • Committer: root
  • Date: 2013-05-16 15:49:25 UTC
  • Revision ID: root@erp.kndati.lv-20130516154925-fwijr8bxlmo6yifk
1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- coding: utf8 -*-
 
3
# es_ES
 
4
################################################################################
 
5
# Spanish language support assembled from contributions provided by:
 
6
#       * mechiscogo
 
7
#       * Christopher Ormaza - Ecuadorenlinea.net <chris.ormaza@gmail.com>, 2011
 
8
################################################################################
 
9
 
 
10
from report_aeroo.ctt_objects import ctt_language
 
11
 
 
12
class es_ES(ctt_language):
 
13
    def _init_lang(self):
 
14
        # language name
 
15
        self.name = 'es_ES'
 
16
        # digits - masculine, singular
 
17
        self.digits_sng_msc = [u'cero', u'uno', u'dos', u'tres', u'cuatro',
 
18
                               u'cinco', u'seis', u'siete', u'ocho', u'nueve']
 
19
 
 
20
        # tens - masculine, singular
 
21
        self.tens_sng_msc = [u'', u'', u'veint', u'treinta', u'cuarenta',
 
22
                             u'cincuenta', u'sesenta', u'setenta', u'ochenta',
 
23
                             u'noventa ']
 
24
        
 
25
        # teens - masculine
 
26
        self.teens = [u'diez', u'once', u'doce', u'trece', u'catorce',
 
27
                      u'quince', u'dieciséis', u'diecisiete', u'dieciocho',
 
28
                      u'diecinueve']
 
29
 
 
30
        # multiplier - masculine, singular
 
31
        self.multi_sng_msc = [u'cien', u' mil', u' millón', u' billón']
 
32
 
 
33
        # multiplier - masculine, plural
 
34
        self.multi_plr_msc = [u'cientos', u' mil', u' millones', u' billones']
 
35
        
 
36
        # next line is needed for correct loading of currencies 
 
37
        import currencies
 
38
        return currencies
 
39
 
 
40
 
 
41
    def wordify(self, chunk, chunknr, gender):
 
42
        if gender == 'm':
 
43
            number = self.digits_sng_msc
 
44
        elif gender == 'f':
 
45
            number = self.digits_sng_fem
 
46
        elif gender == 'n':
 
47
            number = self.digits_sng_neu
 
48
        words = u''
 
49
        digit1 = u''
 
50
        digit2 = u''
 
51
        digit3 = u''
 
52
        chunklength = len(chunk)
 
53
        # placing digits in right places
 
54
        if chunklength == 1:
 
55
            digit3 = chunk[0 : 1]
 
56
        if chunklength == 2:
 
57
            digit2 = chunk[0 : 1]
 
58
            digit3 = chunk[1 : 2]
 
59
        if chunklength == 3:
 
60
            digit1 = chunk[0 : 1]
 
61
            digit2 = chunk[1 : 2]
 
62
            digit3 = chunk[-1]
 
63
        # processing zero
 
64
        if chunklength == 1 and digit3  == '0' :
 
65
            return number[0]
 
66
        # processing hundreds
 
67
        if chunklength == 3 :
 
68
            if digit1 == '1' :
 
69
                words += self.multi_sng_msc[0]
 
70
            else :
 
71
                if int(digit1) >= 1 : words += self.digits_sng_msc[int(digit1)]\
 
72
                                                         + self.multi_plr_msc[0]
 
73
        # processing tens
 
74
        if chunklength > 1:
 
75
            spacer = ''
 
76
            if len(words) > 0 : spacer = u' '
 
77
            if digit2 == '1':
 
78
                words += spacer + self.teens[int(digit3)]
 
79
            else:
 
80
                if int(digit2) > 1 and int(digit2) > 0:
 
81
                    words += spacer + self.tens_sng_msc[int(digit2)]
 
82
                if int(digit3) > 0:
 
83
                    words += u' y'
 
84
 
 
85
        # processing ones
 
86
        if chunklength > 0 and digit2 != '1' :
 
87
            spacer = ''
 
88
            if len(words) > 0: spacer = u' '
 
89
            if int(digit3) > 0:
 
90
                words += spacer + number[int(digit3)]
 
91
        # end processing
 
92
        if len(words) > 0 :
 
93
            if digit3 == '1' and chunknr > 0:
 
94
                return words + self.multi_sng_msc[chunknr]
 
95
            elif digit3 != '1' and chunknr > 0:
 
96
                return words + self.multi_plr_msc[chunknr]
 
97
            else:
 
98
                return words
 
99
        else:
 
100
            return ''
 
101
 
 
102
es_ES()