3 * - Alexander Novikov (mr.pokryshkin@gmail.com)
5 * tts_ru is based on tts_de and tts_en
7 * opentx is based on code named
8 * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
9 * er9x by Erez Raviv: http://code.google.com/p/er9x/,
10 * and the original (and ongoing) project by
11 * Thomas Husterer, th9x: http://code.google.com/p/th9x/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
27 RU_PROMPT_NUMBERS_BASE
= 0,
28 RU_PROMPT_ZERO
= RU_PROMPT_NUMBERS_BASE
+0, //02-99
29 RU_PROMPT_HUNDRED
= RU_PROMPT_NUMBERS_BASE
+100, //100,200 .. 900
31 RU_PROMPT_AND
= RU_PROMPT_NUMBERS_BASE
+110, // и
32 RU_PROMPT_MINUS
= RU_PROMPT_NUMBERS_BASE
+111, // минус
33 RU_PROMPT_UNITS_BASE
= RU_PROMPT_NUMBERS_BASE
+ 113,
34 RU_PROMPT_POINT_BASE
= RU_PROMPT_NUMBERS_BASE
+ 165, //.0 - .9
35 RU_PROMPT_FEMALE_ONE
= RU_PROMPT_NUMBERS_BASE
+ 180,
36 RU_PROMPT_FEMALE_TWO
= RU_PROMPT_NUMBERS_BASE
+ 190,
38 RU_PROMPT_THOUSAND1
= RU_PROMPT_NUMBERS_BASE
+200, //1000
39 RU_PROMPT_THOUSAND2
= RU_PROMPT_NUMBERS_BASE
+201, //2000
40 RU_PROMPT_THOUSAND5
= RU_PROMPT_NUMBERS_BASE
+202, //5000
44 #define RU_FEMALE_UNIT 0xFF
49 #define RU_PUSH_UNIT_PROMPT(u, p) ru_pushUnitPrompt((u), (p), id)
51 #define RU_PUSH_UNIT_PROMPT(u, p) pushUnitPrompt((u), (p))
54 I18N_PLAY_FUNCTION(ru
, pushUnitPrompt
, uint8_t unitprompt
, int16_t number
)
57 if (number
< 0){ // if negative number, we have to use 2 units form (for example value = 1.3)
58 PUSH_UNIT_PROMPT(unitprompt
, 2);
61 int16_t mod10
= number
% 10;
63 PUSH_UNIT_PROMPT(unitprompt
, 0);
65 PUSH_UNIT_PROMPT(unitprompt
, 1);
66 else if (number
>=2 && number
<=4)
67 PUSH_UNIT_PROMPT(unitprompt
, 2);
68 else if (number
>=5 && number
<=20)
69 PUSH_UNIT_PROMPT(unitprompt
, 5);
71 PUSH_UNIT_PROMPT(unitprompt
, 1);
72 else if (mod10
>= 2 && mod10
<=4)
73 PUSH_UNIT_PROMPT(unitprompt
, 2);
75 PUSH_UNIT_PROMPT(unitprompt
, 5);
79 // TODO: add rules for Russian language
80 unitprompt
= RU_PROMPT_UNITS_BASE
+ unitprompt
*4;
82 PUSH_NUMBER_PROMPT(unitprompt
);
84 PUSH_NUMBER_PROMPT(unitprompt
+1);
88 I18N_PLAY_FUNCTION(ru
, playNumber
, getvalue_t number
, uint8_t unit
, uint8_t att
)
91 PUSH_NUMBER_PROMPT(RU_PROMPT_MINUS
);
98 convertUnit(number
, unit
);
99 if (IS_IMPERIAL_ENABLE()) {
100 if (unit
== UNIT_DIST
) {
103 if (unit
== UNIT_SPEED
) {
110 div_t qr
= div((int)number
, 10);
111 int8_t mode
= MODE(att
);
112 if (mode
> 0 && att
!= RU_FEMALE_UNIT
) {
118 // we assume that we are PREC1
121 PLAY_NUMBER(qr
.quot
, 0, 0);
122 PUSH_NUMBER_PROMPT(RU_PROMPT_POINT_BASE
+ qr
.rem
);
130 int16_t tmp
= number
;
132 if (number
>= 1000) {
133 PLAY_NUMBER(number
/ 1000, RU_FEMALE_UNIT
, 0); // female
134 uint8_t thousands
= number
/ 1000;
135 int16_t mod10
= thousands
% 10;
137 PUSH_NUMBER_PROMPT(RU_PROMPT_THOUSAND1
);
138 else if (thousands
>=2 && thousands
<=4)
139 PUSH_NUMBER_PROMPT(RU_PROMPT_THOUSAND2
);
140 else if (thousands
>=5 && thousands
<=20)
141 PUSH_NUMBER_PROMPT(RU_PROMPT_THOUSAND5
);
143 PUSH_NUMBER_PROMPT(RU_PROMPT_THOUSAND1
);
144 else if (mod10
>= 2 && mod10
<=4)
145 PUSH_NUMBER_PROMPT(RU_PROMPT_THOUSAND2
);
147 PUSH_NUMBER_PROMPT(RU_PROMPT_THOUSAND5
);
153 PUSH_NUMBER_PROMPT(RU_PROMPT_HUNDRED
+ (number
/100)-1);
172 uint8_t lastDigit
= number
% 10;
173 uint8_t ten
=(number
- (number
% 10))/10;
174 if (lastDigit
== 1 && number
!= 11 && attr
== FEMALE
)
175 PUSH_NUMBER_PROMPT(RU_PROMPT_FEMALE_ONE
+ ten
);
176 else if (lastDigit
== 2 && number
!=12 && attr
== FEMALE
)
177 PUSH_NUMBER_PROMPT(RU_PROMPT_FEMALE_TWO
+ ten
);
179 PUSH_NUMBER_PROMPT(RU_PROMPT_ZERO
+ number
);
183 if (mode
> 0 && qr
.rem
) // number with decimal point
184 RU_PUSH_UNIT_PROMPT(unit
, -1); // force 2 units form, if float value
186 RU_PUSH_UNIT_PROMPT(unit
, tmp
);
190 I18N_PLAY_FUNCTION(ru
, playDuration
, int seconds PLAY_DURATION_ATT
)
193 PLAY_NUMBER(seconds
, 0, 0);
198 PUSH_NUMBER_PROMPT(RU_PROMPT_MINUS
);
202 uint8_t tmp
= seconds
/ 3600;
204 if (tmp
> 0 || IS_PLAY_TIME()) {
205 PLAY_NUMBER(tmp
, UNIT_HOURS
, 0);
211 PLAY_NUMBER(tmp
, UNIT_MINUTES
, 0);
213 PUSH_NUMBER_PROMPT(RU_PROMPT_AND
);
216 PLAY_NUMBER(seconds
, UNIT_SECONDS
, 0);
220 LANGUAGE_PACK_DECLARE(ru
, "Russian");