Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

lang: Support languages that speak the units before a numerical value

Previously, it was hardcoded to the english convention of units-last, so
"100%" would be voiced as "one hundred percent". This adds a new
language flag that makes the units be voiced first, ie "100%" will be
voiced as "percent one hundred".

So far only the Chinese-traditional and Chinese-simplified languages
utilize this feature (taken from an old ticket, FS#10340) but I'm sure
others would want this feature too.

Change-Id: Idf825ec9299dc0ed09921cf67aec61b1ab262fc6

+25 -4
+2
apps/lang/chinese-simp.lang
··· 13 13 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 14 14 # KIND, either express or implied. 15 15 # 16 + # LANGUAGE_UNITS_FIRST 17 + # 16 18 # Simplified Chinese language file, translated by: 17 19 # - Ye Wei 18 20 # - Xinlu Huang
+2
apps/lang/chinese-trad.lang
··· 13 13 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 14 14 # KIND, either express or implied. 15 15 # 16 + # LANGUAGE_UNITS_FIRST 17 + # 16 18 # Traditional Chinese language file, translated by: 17 19 # - Wenbin Leo 18 20 # - Xinlu Huang
+10 -3
apps/language.c
··· 37 37 /* See tools/genlang (TODO: Use common include for both) */ 38 38 #define LANGUAGE_COOKIE 0x1a 39 39 #define LANGUAGE_VERSION 0x06 40 - #define LANGUAGE_FLAG_RTL 0x01 40 + 41 + #define LANGUAGE_FLAG_RTL 0x01 42 + #define LANGUAGE_FLAG_UNITS_FIRST 0x02 41 43 42 44 #define HEADER_SIZE 4 43 45 #define SUBHEADER_SIZE 6 ··· 54 56 } 55 57 } 56 58 57 - int lang_load(const char *filename, const unsigned char *builtin, 58 - unsigned char **dest, unsigned char *buffer, 59 + int lang_load(const char *filename, const unsigned char *builtin, 60 + unsigned char **dest, unsigned char *buffer, 59 61 unsigned int user_num, int max_lang_size, 60 62 unsigned int max_id) 61 63 { ··· 143 145 { 144 146 return (lang_options & LANGUAGE_FLAG_RTL) != 0; 145 147 } 148 + 149 + int lang_units_first(void) 150 + { 151 + return (lang_options & LANGUAGE_FLAG_UNITS_FIRST) != 0; 152 + }
+2
apps/language.h
··· 37 37 38 38 /* returns whether the loaded language is a right-to-left language */ 39 39 int lang_is_rtl(void); 40 + /* returns whether the loaded language needs units spoken before the value */ 41 + int lang_units_first(void); 40 42 #endif
+5 -1
apps/talk.c
··· 35 35 #include "voice_thread.h" 36 36 #include "audio.h" 37 37 #include "lang.h" 38 + #include "language.h" 38 39 #include "talk.h" 39 40 #include "metadata.h" 40 41 /*#define LOGF_ENABLE*/ ··· 1419 1420 return 0; 1420 1421 } 1421 1422 1423 + if (lang_units_first()) 1424 + talk_id(unit_id, true); /* say the unit, if any */ 1422 1425 talk_number(n, enqueue); /* say the number */ 1423 - talk_id(unit_id, true); /* say the unit, if any */ 1426 + if (!lang_units_first()) 1427 + talk_id(unit_id, true); /* say the unit, if any */ 1424 1428 1425 1429 return 0; 1426 1430 }
+4
tools/genlang
··· 16 16 my $VOICE_COOKIE = 0x9a; 17 17 my $LANGUAGE_VERSION = 0x06; 18 18 my $LANGUAGE_FLAG_RTL = 0x01; 19 + my $LANGUAGE_FLAG_UNITS_FIRST = 0x02; 19 20 20 21 my $HEADER_SIZE = 4; 21 22 my $SUBHEADER_SIZE = 6; ··· 371 372 # comment or empty line - output it if it's part of the header 372 373 if ($_ =~ /LANGUAGE_IS_RTL/) { 373 374 $langoptions |= $LANGUAGE_FLAG_RTL; 375 + } 376 + if ($_ =~ /LANGUAGE_UNITS_FIRST/) { 377 + $langoptions |= $LANGUAGE_FLAG_UNITS_FIRST; 374 378 } 375 379 376 380 if ($header and $sortfile) {