From 5ba8fc4a683195a8218e284be8d2203544bde14f Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 26 Aug 2023 13:09:41 +0200 Subject: [PATCH] fix: Plurals and indefinite articles in German TTS, plus (#3920) - fixed no LUA constant for unit dbm - fixed use plurals and indefinite articles in German TTS --- radio/src/audio.cpp | 2 +- radio/src/lua/api_general.cpp | 1 + radio/src/translations/tts_de.cpp | 36 +++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/radio/src/audio.cpp b/radio/src/audio.cpp index f25ceb0a766..850dd44ba71 100644 --- a/radio/src/audio.cpp +++ b/radio/src/audio.cpp @@ -159,7 +159,7 @@ const char * const unitsFilenames[] = { "rpm", "g", "degree", - "radian", + "rad", "ml", "founce", "mlpm", diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 073da1b00f9..880e4dd9ec1 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -3185,6 +3185,7 @@ LROT_BEGIN(etxcst, NULL, 0) LROT_NUMENTRY( UNIT_HERTZ, UNIT_HERTZ ) LROT_NUMENTRY( UNIT_MS, UNIT_MS ) LROT_NUMENTRY( UNIT_US, UNIT_US ) + LROT_NUMENTRY( UNIT_DBM, UNIT_DBM ) LROT_NUMENTRY( UNIT_HOURS, UNIT_HOURS ) LROT_NUMENTRY( UNIT_MINUTES, UNIT_MINUTES ) LROT_NUMENTRY( UNIT_SECONDS, UNIT_SECONDS ) diff --git a/radio/src/translations/tts_de.cpp b/radio/src/translations/tts_de.cpp index ed89eab25ec..85a33f0145e 100644 --- a/radio/src/translations/tts_de.cpp +++ b/radio/src/translations/tts_de.cpp @@ -64,11 +64,23 @@ enum GermanPrompts { }; - #define DE_PUSH_UNIT_PROMPT(u) de_pushUnitPrompt((u), id) + #define DE_PUSH_UNIT_PROMPT(u, p) de_pushUnitPrompt((u), (p), id) -I18N_PLAY_FUNCTION(de, pushUnitPrompt, uint8_t unitprompt) +I18N_PLAY_FUNCTION(de, pushUnitPrompt, uint8_t unitprompt, int16_t number) { - PUSH_UNIT_PROMPT(unitprompt, 0); + if(number != 1 && // do plurals for this list of units if number is not 1 + (unitprompt == UNIT_HOURS || + unitprompt == UNIT_MINUTES || + unitprompt == UNIT_SECONDS || + unitprompt == UNIT_FLOZ || + unitprompt == UNIT_MS || + unitprompt == UNIT_US || + unitprompt == UNIT_RADIANS || + unitprompt == UNIT_MAH)) { + PUSH_UNIT_PROMPT(unitprompt, 1); // push xxx1.wav for plural version + } + else + PUSH_UNIT_PROMPT(unitprompt, 0); // push xxx0.wav for singular version } I18N_PLAY_FUNCTION(de, playNumber, getvalue_t number, uint8_t unit, uint8_t att) @@ -109,10 +121,12 @@ I18N_PLAY_FUNCTION(de, playNumber, getvalue_t number, uint8_t unit, uint8_t att) } } if(unit) - DE_PUSH_UNIT_PROMPT(unit); + DE_PUSH_UNIT_PROMPT(unit, qr.quot); return; } + int16_t tmp = number; + if (number >= 2000) { PLAY_NUMBER(number / 1000, 0, 0); PUSH_NUMBER_PROMPT(DE_PROMPT_TAUSEND); @@ -146,11 +160,21 @@ I18N_PLAY_FUNCTION(de, playNumber, getvalue_t number, uint8_t unit, uint8_t att) } if (number >= 0) { - PUSH_NUMBER_PROMPT(DE_PROMPT_NULL + number / 1); + if(number == 1) { + if(unit == UNIT_HOURS || + unit == UNIT_MINUTES || + unit == UNIT_SECONDS || + unit == UNIT_FLOZ || + unit == UNIT_MS || + unit == UNIT_US || + unit == UNIT_MAH) + PUSH_NUMBER_PROMPT(DE_PROMPT_EINE); // "eine ..." + } else + PUSH_NUMBER_PROMPT(DE_PROMPT_NULL + number / 1); // "ein ..."" } if (unit) { - DE_PUSH_UNIT_PROMPT(unit); + DE_PUSH_UNIT_PROMPT(unit, tmp); } }