diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2021-09-21 19:16:23 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2021-09-28 17:25:28 -0400 |
commit | 70e72e01d24bd6fe1e9ef15bcf3ceeccb69e2d6b (patch) | |
tree | 6952891e98ea47b3b7b2a8d621087bf9b7340b5b /apps/talk.c | |
parent | 3cc7509e815787b6f528282b0c14b4b09fa18a05 (diff) | |
download | rockbox-70e72e01d24bd6fe1e9ef15bcf3ceeccb69e2d6b.tar.gz rockbox-70e72e01d24bd6fe1e9ef15bcf3ceeccb69e2d6b.zip |
talk: Add support for languages that swap the tens position in numbers
For example, English would say "231" as "two hundred thirty one" but
many other languages would say "two hundred one and thirty"
So, if VOICE_NUMERIC_TENS_SWAP_SEPARATOR is not an empty string, swap
the tens and ones position and use that string ("and" in the above
example) as the voiced separator.
Change-Id: I69f8064d44b3995827327cabae6ad352bf257d04
Diffstat (limited to 'apps/talk.c')
-rw-r--r-- | apps/talk.c | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/apps/talk.c b/apps/talk.c index 73191c22c3..e627337162 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -1188,17 +1188,44 @@ int talk_number(long n, bool enqueue) | |||
1188 | talk_id(VOICE_HUNDRED, true); | 1188 | talk_id(VOICE_HUNDRED, true); |
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | /* combination indexing */ | 1191 | struct queue_entry tens_swap; |
1192 | if (ones > 20) | 1192 | if (get_clip(VOICE_NUMERIC_TENS_SWAP_SEPARATOR, &tens_swap) >= 0) |
1193 | { | 1193 | { |
1194 | int tens = ones/10 + 18; | 1194 | /* direct indexing */ |
1195 | talk_id(VOICE_ZERO + tens, true); | 1195 | if (ones <= 20) |
1196 | ones %= 10; | 1196 | { |
1197 | talk_id(VOICE_ZERO + ones, true); | ||
1198 | } | ||
1199 | else if (ones) | ||
1200 | { | ||
1201 | int tmp = ones % 10; | ||
1202 | if (tmp) | ||
1203 | { | ||
1204 | talk_id(VOICE_ZERO + tmp, true); | ||
1205 | talk_id(VOICE_NUMERIC_TENS_SWAP_SEPARATOR, true); | ||
1206 | } | ||
1207 | } | ||
1208 | /* combination indexing */ | ||
1209 | if (ones > 20) | ||
1210 | { | ||
1211 | int tens = ones/10 + 18; | ||
1212 | talk_id(VOICE_ZERO + tens, true); | ||
1213 | } | ||
1197 | } | 1214 | } |
1215 | else | ||
1216 | { | ||
1217 | /* combination indexing */ | ||
1218 | if (ones > 20) | ||
1219 | { | ||
1220 | int tens = ones/10 + 18; | ||
1221 | talk_id(VOICE_ZERO + tens, true); | ||
1222 | ones %= 10; | ||
1223 | } | ||
1198 | 1224 | ||
1199 | /* direct indexing */ | 1225 | /* direct indexing */ |
1200 | if (ones) | 1226 | if (ones) |
1201 | talk_id(VOICE_ZERO + ones, true); | 1227 | talk_id(VOICE_ZERO + ones, true); |
1228 | } | ||
1202 | 1229 | ||
1203 | /* add billion, million, thousand */ | 1230 | /* add billion, million, thousand */ |
1204 | if (mil) | 1231 | if (mil) |
@@ -1215,7 +1242,7 @@ int talk_number(long n, bool enqueue) | |||
1215 | static int talk_year(long year, bool enqueue) | 1242 | static int talk_year(long year, bool enqueue) |
1216 | { | 1243 | { |
1217 | int rem; | 1244 | int rem; |
1218 | if(year < 1100 || year >=2000) | 1245 | if(year < 1100 || (year >=2000 && year < 2100)) |
1219 | /* just say it as a regular number */ | 1246 | /* just say it as a regular number */ |
1220 | return talk_number(year, enqueue); | 1247 | return talk_number(year, enqueue); |
1221 | /* Say century */ | 1248 | /* Say century */ |