~anybox/aeroo/openerp6

« back to all changes in this revision

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

  • Committer: root
  • Date: 2013-05-16 15:46:46 UTC
  • Revision ID: root@erp.kndati.lv-20130516154646-5lesr8tyzl1vdc0k
1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- coding: utf8 -*-
 
3
# uk_UA
 
4
 
 
5
from report_aeroo.ctt_objects import ctt_language
 
6
 
 
7
class uk_UA(ctt_language):
 
8
    def _init_lang(self):
 
9
        # language name
 
10
        self.name = 'uk_UA'
 
11
        # digits - masculine, singular
 
12
        self.number_sng_msc = [u'ноль', u'один', u'два', u'три', u'чотири',
 
13
                               u'п\'ять', u'шість', u'сім', u'вісім',
 
14
                               u'дев\'ять']
 
15
        # tens - masculine, singular
 
16
        self.number_sng_fem = [u'ноль', u'одна', u'дві', u'три', u'чотири', 
 
17
                               u'п\'ять', u'шість', u'сім', u'вісім',
 
18
                               u'дев\'ять']
 
19
        # tens - masculine, plural
 
20
        self.number_plr_msc = [u'', u'один', u'двa', u'три', u'четыре', u'пять',
 
21
                               u'шесть', u'семь', u'восемь', u'девять']
 
22
        # teens - masculine
 
23
        self.number_teens = [u'десять', u'одинадцять', u'дванадцять',
 
24
                             u'тринадцять', u'чотирнадцять', u'п\'ятнадцять',
 
25
                             u'шістнадцять', u'сімнадцять', u'вісімнадцять',
 
26
                             u'дев\'ятнадцять']
 
27
        # multiplier - masculine, singular                      
 
28
        self.multi_sng_msc = [u'стo', u' тисяча', u' мiллiон', u' мiллiард']
 
29
        # multiplier - masculine, plural
 
30
        self.multi_plr_msc = [u'сoт', u' тисяч', u' мiллiонiв', u' мiллiардов']
 
31
        
 
32
        # next line is needed for correct loading of currencies 
 
33
        import currencies
 
34
        return currencies
 
35
 
 
36
 
 
37
    def wordify(self, chunk, chunknr, gender):
 
38
        if gender == 'm':
 
39
            number = self.number_sng_msc
 
40
        elif gender == 'f':
 
41
            number = self.number_sng_fem
 
42
        elif gender == 'n':
 
43
            number = self.number_sng_neu
 
44
        words = u''
 
45
        digit1 = u''
 
46
        digit2 = u''
 
47
        digit3 = u''
 
48
        chunklength = len(chunk)
 
49
        # placing digits in right places
 
50
        if chunklength == 1:
 
51
            digit3 = chunk[0 : 1]
 
52
        if chunklength == 2:
 
53
            digit2 = chunk[0 : 1]
 
54
            digit3 = chunk[1 : 2]
 
55
        if chunklength == 3:
 
56
            digit1 = chunk[0 : 1]
 
57
            digit2 = chunk[1 : 2]
 
58
            digit3 = chunk[-1]
 
59
        # processing zero
 
60
        if chunklength == 1 and digit3  == '0' :
 
61
            return number[0]
 
62
        # processing hundreds
 
63
        if chunklength == 3 :
 
64
            if int(digit1) == 1 :
 
65
                words += self.multi_sng_msc[0]
 
66
            elif int(digit1) == 2 :
 
67
                words += u'двісті'
 
68
            elif int(digit1) == 3 :
 
69
                words += u'триста'
 
70
            elif int(digit1) == 4 :
 
71
                words += u'чотириста'
 
72
            elif int(digit1) >= 5 :
 
73
                words += self.number_sng_msc[int(digit1)] + self.multi_plr_msc[0]
 
74
        # processing tens
 
75
        if chunklength > 1:
 
76
            spacer = ''
 
77
            if len(words) > 0 : spacer = ' '
 
78
            if digit2 == '1':
 
79
                words += spacer + self.number_teens[int(digit3)]
 
80
            else:
 
81
                        if int(digit2) > 1 and int(digit2) < 4:
 
82
                            words += spacer + skaitlix[int(digit2)] + u'дцять'
 
83
                        elif digit2 == '4':
 
84
                            words += spacer + u'сорок'
 
85
                        elif int(digit2) >= 5 and int(digit2) != 9:
 
86
                            words += spacer + skaitlix[int(digit2)] + u'десят'
 
87
                        elif digit2 == '9':
 
88
                            words += spacer + u'дев\'яносто'
 
89
 
 
90
        # processing ones
 
91
        if chunklength > 0 and digit2 != '1' :
 
92
            spacer = ''
 
93
            if len(words) > 0: spacer = u' '
 
94
            if chunknr == 1:
 
95
                if int(digit3) == 1 or int(digit3) == 2:
 
96
                    words += spacer + self.number_sng_fem[int(digit3)]
 
97
                elif int(digit3) >= 3 and int(digit3) != 0: 
 
98
                    words += spacer + self.number_sng_msc[int(digit3)]
 
99
            else:
 
100
                if int(digit3) > 0: words += spacer + self.number_sng_msc[int(digit3)]
 
101
        # end processing
 
102
        if len(words) > 0 :
 
103
            if digit3 == '1' and chunknr > 0:
 
104
                return words + self.multi_sng_msc[chunknr]
 
105
            elif digit3 != '1' and chunknr > 0:
 
106
                return words + self.multi_plr_msc[chunknr]
 
107
            else:
 
108
                return words
 
109
        else:
 
110
            return ''
 
111
 
 
112
uk_UA()