Improve multi (#7136)
[opentx.git] / radio / src / translations / tts_it.cpp
blobce4a167cacc520c8a37307d23a1ff74ae7091bb1
1 /*
2 * Authors (alphabetical order)
3 * - Bertrand Songis <bsongis@gmail.com>
4 * - Romolo Manfredini <romolo.manfredini@gmail.com>
6 * opentx is based on code named
7 * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
8 * er9x by Erez Raviv: http://code.google.com/p/er9x/,
9 * and the original (and ongoing) project by
10 * Thomas Husterer, th9x: http://code.google.com/p/th9x/
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
23 #include "opentx.h"
25 enum ItalianPrompts {
26 IT_PROMPT_NUMBERS_BASE = 0,
27 IT_PROMPT_ZERO = IT_PROMPT_NUMBERS_BASE+0,
28 IT_PROMPT_CENT = IT_PROMPT_NUMBERS_BASE+100,
29 IT_PROMPT_MILA = IT_PROMPT_NUMBERS_BASE+101,
30 IT_PROMPT_MILLE = IT_PROMPT_NUMBERS_BASE+102,
31 IT_PROMPT_VIRGOLA = 103,
32 IT_PROMPT_UN,
33 IT_PROMPT_E,
34 IT_PROMPT_MENO,
35 IT_PROMPT_ORA,
36 IT_PROMPT_ORE,
37 IT_PROMPT_MINUTO,
38 IT_PROMPT_MINUTI,
39 IT_PROMPT_SECONDO,
40 IT_PROMPT_SECONDI,
42 IT_PROMPT_UNITS_BASE = 113,
43 IT_PROMPT_VOLTS = IT_PROMPT_UNITS_BASE+(UNIT_VOLTS*2),
44 IT_PROMPT_AMPS = IT_PROMPT_UNITS_BASE+(UNIT_AMPS*2),
45 IT_PROMPT_METERS_PER_SECOND = IT_PROMPT_UNITS_BASE+(UNIT_METERS_PER_SECOND*2),
46 IT_PROMPT_SPARE1 = IT_PROMPT_UNITS_BASE+(UNIT_RAW*2),
47 IT_PROMPT_KMH = IT_PROMPT_UNITS_BASE+(UNIT_SPEED*2),
48 IT_PROMPT_METERS = IT_PROMPT_UNITS_BASE+(UNIT_DIST*2),
49 IT_PROMPT_DEGREES = IT_PROMPT_UNITS_BASE+(UNIT_TEMPERATURE*2),
50 IT_PROMPT_PERCENT = IT_PROMPT_UNITS_BASE+(UNIT_PERCENT*2),
51 IT_PROMPT_MILLIAMPS = IT_PROMPT_UNITS_BASE+(UNIT_MILLIAMPS*2),
52 IT_PROMPT_MAH = IT_PROMPT_UNITS_BASE+(UNIT_MAH*2),
53 IT_PROMPT_WATTS = IT_PROMPT_UNITS_BASE+(UNIT_WATTS*2),
54 IT_PROMPT_FEET = IT_PROMPT_UNITS_BASE+(UNIT_FEET*2),
55 IT_PROMPT_KTS = IT_PROMPT_UNITS_BASE+(UNIT_KTS*2),
56 IT_PROMPT_MILLILITERS = IT_PROMPT_UNITS_BASE+(UNIT_MILLILITERS*2),
57 IT_PROMPT_FLOZ = IT_PROMPT_UNITS_BASE+(UNIT_FLOZ*2),
58 IT_PROMPT_FEET_PER_SECOND = IT_PROMPT_UNITS_BASE+(UNIT_FEET_PER_SECOND*2),
62 #define IT_PUSH_UNIT_PROMPT(u, p) it_pushUnitPrompt((u), (p), id)
64 I18N_PLAY_FUNCTION(it, pushUnitPrompt, uint8_t unitprompt, int16_t number)
66 if (number == 1)
67 PUSH_UNIT_PROMPT(unitprompt, 0);
68 else
69 PUSH_UNIT_PROMPT(unitprompt, 1);
73 I18N_PLAY_FUNCTION(it, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
75 /* if digit >= 1000000000:
76 temp_digit, digit = divmod(digit, 1000000000)
77 prompts.extend(self.getNumberPrompt(temp_digit))
78 prompts.append(Prompt(GUIDE_00_BILLION, dir=2))
79 if digit >= 1000000:
80 temp_digit, digit = divmod(digit, 1000000)
81 prompts.extend(self.getNumberPrompt(temp_digit))
82 prompts.append(Prompt(GUIDE_00_MILLION, dir=2))
84 getvalue_t orignumber;
85 if (number < 0) {
86 PUSH_NUMBER_PROMPT(IT_PROMPT_MENO);
87 number = -number;
89 orignumber=number;
91 int8_t mode = MODE(att);
92 if (mode > 0) {
93 if (mode == 2) {
94 number /= 10;
96 div_t qr = div((int)number, 10);
97 if (qr.rem > 0) {
98 PLAY_NUMBER(qr.quot, 0, 0);
99 PUSH_NUMBER_PROMPT(IT_PROMPT_VIRGOLA);
100 if (mode==2 && qr.rem < 10)
101 PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO);
102 PLAY_NUMBER(qr.rem, 0, 0);
104 else {
105 if (qr.quot==1) {
106 PUSH_NUMBER_PROMPT(IT_PROMPT_UN);
107 if (unit) {
108 PUSH_NUMBER_PROMPT(IT_PROMPT_UNITS_BASE+(unit*2));
110 return;
111 } else {
112 PLAY_NUMBER(qr.quot, 0, 0);
115 } else {
116 if (orignumber == 1 && unit) {
117 PUSH_NUMBER_PROMPT(IT_PROMPT_UN);
118 } else {
119 if (number >= 1000) {
120 if (number >= 2000) {
121 PLAY_NUMBER(number / 1000, 0, 0);
122 PUSH_NUMBER_PROMPT(IT_PROMPT_MILA);
123 } else {
124 PUSH_NUMBER_PROMPT(IT_PROMPT_MILLE);
126 number %= 1000;
127 if (number == 0)
128 number = -1;
130 if (number >= 100) {
131 if (number >= 200)
132 PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO + number/100);
133 PUSH_NUMBER_PROMPT(IT_PROMPT_CENT);
134 number %= 100;
135 if (number == 0)
136 number = -1;
138 PUSH_NUMBER_PROMPT(IT_PROMPT_ZERO+number);
141 if (unit) {
142 IT_PUSH_UNIT_PROMPT(unit, orignumber);
146 I18N_PLAY_FUNCTION(it, playDuration, int seconds PLAY_DURATION_ATT)
148 if (seconds == 0) {
149 PLAY_NUMBER(seconds, 0, 0);
150 return;
153 if (seconds < 0) {
154 PUSH_NUMBER_PROMPT(IT_PROMPT_MENO);
155 seconds = -seconds;
158 uint8_t tmp = seconds / 3600;
159 seconds %= 3600;
160 if (tmp > 0 || IS_PLAY_TIME()) {
161 PLAY_NUMBER(tmp, UNIT_HOURS, 0);
164 tmp = seconds / 60;
165 seconds %= 60;
166 if (tmp > 0) {
167 PLAY_NUMBER(tmp, UNIT_MINUTES, 0);
168 if (seconds > 0)
169 PUSH_NUMBER_PROMPT(IT_PROMPT_E);
172 if (seconds > 0) {
173 PLAY_NUMBER(seconds, UNIT_SECONDS, 0);
177 LANGUAGE_PACK_DECLARE(it, "Italiano");