Improve multi (#7136)
[opentx.git] / radio / src / translations / tts_cz.cpp
blobc3277d54f31520d826f96c07573d76ef1442616d
1 /*
2 * Authors (alphabetical order)
3 * - Bertrand Songis <bsongis@gmail.com>
4 * - Martin Hotar <mhotar@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 CzechPrompts {
26 CZ_PROMPT_NUMBERS_BASE = 0,
27 CZ_PROMPT_NULA = CZ_PROMPT_NUMBERS_BASE+0, // 0-99
28 CZ_PROMPT_STO = CZ_PROMPT_NUMBERS_BASE+100, // 100,200 .. 900
29 CZ_PROMPT_TISIC = CZ_PROMPT_NUMBERS_BASE+109, // 1000
30 CZ_PROMPT_TISICE = CZ_PROMPT_NUMBERS_BASE+110,
31 CZ_PROMPT_JEDEN = CZ_PROMPT_NUMBERS_BASE+111,
32 CZ_PROMPT_JEDNO = CZ_PROMPT_NUMBERS_BASE+112,
33 CZ_PROMPT_DVE = CZ_PROMPT_NUMBERS_BASE+113,
34 CZ_PROMPT_CELA = CZ_PROMPT_NUMBERS_BASE+114,
35 CZ_PROMPT_CELE = CZ_PROMPT_NUMBERS_BASE+115,
36 CZ_PROMPT_CELYCH = CZ_PROMPT_NUMBERS_BASE+116,
37 CZ_PROMPT_MINUS = CZ_PROMPT_NUMBERS_BASE+117,
39 CZ_PROMPT_UNITS_BASE = 118, // (jeden)volt,(dva)volty,(pet)voltu,(desetina)voltu
43 #define CZ_PUSH_UNIT_PROMPT(u, p) cz_pushUnitPrompt((u), (p), id)
45 #define MALE 0x80
46 #define FEMALE 0x81
47 #define NEUTRAL 0x82
49 I18N_PLAY_FUNCTION(cz, pushUnitPrompt, uint8_t unit, int16_t number)
51 TRACE("CZSAY unit:%d number:%d", unit, number);
52 if (number == 1)
53 PUSH_UNIT_PROMPT(unit, 0);
54 else if (number > 1 && number < 5)
55 PUSH_UNIT_PROMPT(unit, 1);
56 else
57 PUSH_UNIT_PROMPT(unit, 2);
60 I18N_PLAY_FUNCTION(cz, playNumber, getvalue_t number, uint8_t unit, uint8_t att)
62 if (number < 0) {
63 PUSH_NUMBER_PROMPT(CZ_PROMPT_MINUS);
64 number = -number;
68 int8_t mode = MODE(att);
69 if (mode > 0) {
70 if (mode == 2) {
71 number /= 10;
73 div_t qr = div((int)number, 10);
74 if (qr.rem) {
75 PLAY_NUMBER(qr.quot, 0, FEMALE);
76 if (qr.quot < 2) {
77 PUSH_NUMBER_PROMPT(CZ_PROMPT_CELA);
79 else if (qr.quot > 1 && qr.quot < 5) {
80 PUSH_NUMBER_PROMPT(CZ_PROMPT_CELE);
82 else {
83 PUSH_NUMBER_PROMPT(CZ_PROMPT_CELYCH);
85 PLAY_NUMBER(qr.rem, 0, FEMALE);
86 PUSH_UNIT_PROMPT(unit, 3);
87 return;
89 else {
90 number = qr.quot;
94 int16_t tmp = number;
95 switch(unit) {
96 case UNIT_RAW:
97 break;
98 case UNIT_FEET_PER_SECOND:
99 case UNIT_MPH:
100 case UNIT_FEET:
101 case UNIT_MAH:
102 case UNIT_RPMS:
103 case UNIT_FLOZ:
104 case UNIT_HOURS:
105 case UNIT_MINUTES:
106 case UNIT_SECONDS:
107 att = FEMALE;
108 break;
109 case UNIT_PERCENT:
110 case UNIT_G:
111 att = NEUTRAL;
112 break;
113 default:
114 att = MALE;
115 break;
118 if ((number == 1) && (att == MALE)) {
119 PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDEN);
120 number = -1;
123 if ((number == 1) && (att == NEUTRAL)) {
124 PUSH_NUMBER_PROMPT(CZ_PROMPT_JEDNO);
125 number = -1;
128 if ((number == 2) && ((att == FEMALE) || (att == NEUTRAL))) {
129 PUSH_NUMBER_PROMPT(CZ_PROMPT_DVE);
130 number = -1;
133 if (number >= 1000) {
134 if (number >= 2000)
135 PLAY_NUMBER(number / 1000, 0, 0);
136 if (number >= 2000 && number < 5000)
137 PUSH_NUMBER_PROMPT(CZ_PROMPT_TISICE);
138 else
139 PUSH_NUMBER_PROMPT(CZ_PROMPT_TISIC);
140 number %= 1000;
141 if (number == 0)
142 number = -1;
144 if (number >= 100) {
145 PUSH_NUMBER_PROMPT(CZ_PROMPT_STO + (number/100)-1);
146 number %= 100;
147 if (number == 0)
148 number = -1;
151 if (number >= 0) {
152 PUSH_NUMBER_PROMPT(CZ_PROMPT_NULA+number);
155 if (unit) {
156 CZ_PUSH_UNIT_PROMPT(unit, tmp);
160 I18N_PLAY_FUNCTION(cz, playDuration, int seconds PLAY_DURATION_ATT)
162 if (seconds < 0) {
163 PUSH_NUMBER_PROMPT(CZ_PROMPT_MINUS);
164 seconds = -seconds;
167 uint8_t tmp = seconds / 3600;
168 seconds %= 3600;
169 if (tmp > 0 || IS_PLAY_TIME()) {
170 PLAY_NUMBER(tmp, UNIT_HOURS, FEMALE);
173 tmp = seconds / 60;
174 seconds %= 60;
175 if (tmp > 0) {
176 PLAY_NUMBER(tmp, UNIT_MINUTES, FEMALE);
179 if (seconds > 0) {
180 PLAY_NUMBER(seconds, UNIT_SECONDS, FEMALE);
184 LANGUAGE_PACK_DECLARE(cz, "Czech");