summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2021-09-21 19:16:23 -0400
committerSolomon Peachy <pizza@shaftnet.org>2021-09-28 17:25:28 -0400
commit70e72e01d24bd6fe1e9ef15bcf3ceeccb69e2d6b (patch)
tree6952891e98ea47b3b7b2a8d621087bf9b7340b5b
parent3cc7509e815787b6f528282b0c14b4b09fa18a05 (diff)
downloadrockbox-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
-rw-r--r--apps/lang/dansk.lang14
-rw-r--r--apps/lang/english-us.lang14
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/talk.c45
-rwxr-xr-xtools/updatelang14
5 files changed, 86 insertions, 15 deletions
diff --git a/apps/lang/dansk.lang b/apps/lang/dansk.lang
index 536ecb28ec..aff651cc52 100644
--- a/apps/lang/dansk.lang
+++ b/apps/lang/dansk.lang
@@ -12652,3 +12652,17 @@
12652 *: "Start auto-sluk ved opstart" 12652 *: "Start auto-sluk ved opstart"
12653 </voice> 12653 </voice>
12654</phrase> 12654</phrase>
12655<phrase>
12656 id: VOICE_NUMERIC_TENS_SWAP_SEPARATOR
12657 desc: voice only, for speaking numbers in languages that swap the tens and ones fields. Leave blank for languages that do not need it, such as English ("231" => "two hundred thirty one") but other languages may speak it as "two hundred one [AND] thirty"
12658 user: core
12659 <source>
12660 *: ""
12661 </source>
12662 <dest>
12663 *: ""
12664 </dest>
12665 <voice>
12666 *: "og"
12667 </voice>
12668</phrase>
diff --git a/apps/lang/english-us.lang b/apps/lang/english-us.lang
index 14b33569d2..b926b4e37e 100644
--- a/apps/lang/english-us.lang
+++ b/apps/lang/english-us.lang
@@ -16013,3 +16013,17 @@
16013 *: "Bit rate" 16013 *: "Bit rate"
16014 </voice> 16014 </voice>
16015</phrase> 16015</phrase>
16016<phrase>
16017 id: VOICE_NUMERIC_TENS_SWAP_SEPARATOR
16018 desc: voice only, for speaking numbers in languages that swap the tens and ones fields. Leave blank for languages that do not need it, such as English ("231" => "two hundred thirty one") but other languages may speak it as "two hundred one [AND] thirty"
16019 user: core
16020 <source>
16021 *: ""
16022 </source>
16023 <dest>
16024 *: ""
16025 </dest>
16026 <voice>
16027 *: ""
16028 </voice>
16029</phrase>
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 67624aa2a3..60cb17d245 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -16080,3 +16080,17 @@
16080 *: "Bit rate" 16080 *: "Bit rate"
16081 </voice> 16081 </voice>
16082</phrase> 16082</phrase>
16083<phrase>
16084 id: VOICE_NUMERIC_TENS_SWAP_SEPARATOR
16085 desc: voice only, for speaking numbers in languages that swap the tens and ones fields. Leave blank for languages that do not need it, such as English ("231" => "two hundred thirty one") but other languages may speak it as "two hundred one [AND] thirty"
16086 user: core
16087 <source>
16088 *: ""
16089 </source>
16090 <dest>
16091 *: ""
16092 </dest>
16093 <voice>
16094 *: ""
16095 </voice>
16096</phrase>
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)
1215static int talk_year(long year, bool enqueue) 1242static 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 */
diff --git a/tools/updatelang b/tools/updatelang
index 48f447d074..bde1dedaea 100755
--- a/tools/updatelang
+++ b/tools/updatelang
@@ -370,12 +370,14 @@ foreach my $id (@langorder) {
370# print "#!! '$id:$tgt' voice is blank ('$lp{$tgt}' vs '$ep{$tgt}')\n"; 370# print "#!! '$id:$tgt' voice is blank ('$lp{$tgt}' vs '$ep{$tgt}')\n";
371 $lang{$id}{'voice'}{$tgt} = $english{$id}{'voice'}{$tgt}; 371 $lang{$id}{'voice'}{$tgt} = $english{$id}{'voice'}{$tgt};
372 } elsif ($lp{$tgt} ne '' && $ep{$tgt} eq '') { 372 } elsif ($lp{$tgt} ne '' && $ep{$tgt} eq '') {
373 # If it's not blank, clear it and complain! 373 if ($id ne 'VOICE_NUMERIC_TENS_SWAP_SEPARATOR') {
374 $lang{$id}{'notes'} .= "### The <voice> section for '$id:$tgt' is not blank!\n"; 374 # If it's not blank, clear it and complain!
375 $lang{$id}{'notes'} .= "### the previously used one is commented below:\n"; 375 $lang{$id}{'notes'} .= "### The <voice> section for '$id:$tgt' is not blank!\n";
376 $lang{$id}{'notes'} .= "### $english{$id}{voice}{$tgt}\n"; 376 $lang{$id}{'notes'} .= "### the previously used one is commented below:\n";
377# print "#!! '$id:$tgt' voice not blank ('$lp{$tgt}' vs '$ep{$tgt}')\n"; 377 $lang{$id}{'notes'} .= "### $english{$id}{voice}{$tgt}\n";
378 $lang{$id}{'voice'}{$tgt} = $english{$id}{'voice'}{$tgt}; 378 # print "#!! '$id:$tgt' voice not blank ('$lp{$tgt}' vs '$ep{$tgt}')\n";
379 $lang{$id}{'voice'}{$tgt} = $english{$id}{'voice'}{$tgt};
380 }
379 } 381 }
380 } elsif ($lp{$tgt} ne 'none' && $lp{$tgt} ne '' && not_ignorelist($id) && !$lang{$id}{'new'} && !$ignoredups) { 382 } elsif ($lp{$tgt} ne 'none' && $lp{$tgt} ne '' && not_ignorelist($id) && !$lang{$id}{'new'} && !$ignoredups) {
381 $lang{$id}{'notes'} .= "### The <voice> section for '$id:$tgt' is identical to english!\n"; 383 $lang{$id}{'notes'} .= "### The <voice> section for '$id:$tgt' is identical to english!\n";