Skip to content

Commit

Permalink
fix(color): Inactivity alarm suffix proper grammar (singular/plural) (E…
Browse files Browse the repository at this point in the history
…dgeTX#3064)

* Add translations for "minutes"

* Add missing PLURAL2

* fix grammar

* Next attempt

* include limits.h

* minor cleanup

* Addin some translations for some languages based on inputs

* chore: Remove BREAKSPACE, add ignore flag
And some minor cleanup / formatting

* chore: Revert `TR_USE_VARIABLE_PLURAL`
Use `TR_USE_SINGULAR_IN_PLURAL` properly... thanks @eshifri

Co-authored-by: eshifri <eshifri@hotmail.com>
  • Loading branch information
pfeerick and eshifri authored Jan 20, 2023
1 parent fd04f4a commit 15dca01
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 7 deletions.
35 changes: 30 additions & 5 deletions radio/src/gui/colorlcd/radio_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,43 @@ class AlarmsPage : public Page {
new StaticText(line, rect_t{}, STR_INACTIVITYALARM, 0, COLOR_THEME_PRIMARY1);
edit = new NumberEdit(line, rect_t{}, 0, 250, GET_SET_DEFAULT(g_eeGeneral.inactivityTimer));
lv_obj_set_style_grid_cell_x_align(edit->getLvObj(), LV_GRID_ALIGN_STRETCH, 0);
edit->setSuffix("minutes");

edit->setDisplayHandler([=](int value) -> std::string {
std::string suffix(STR_MINUTE_PLURAL2);
if (value == 1) {
suffix = std::string(STR_MINUTE_SINGULAR);
} else if (value < g_use_plural2) {
const int secondDecimal = (value / 10) % 10;
if (secondDecimal != 1) {
const int firstDecimal = value % 10;
if (firstDecimal) {
if (firstDecimal < g_min_plural2 &&
firstDecimal == g_use_singular_in_plural) {
suffix = std::string(STR_MINUTE_SINGULAR);
} else if (firstDecimal <= g_max_plural2 &&
firstDecimal != g_use_plural2_special_case) {
suffix = std::string(STR_MINUTE_PLURAL1);
}
}
}
}
suffix = " " + suffix;
return formatNumberAsString(value, 0, 0, nullptr, suffix.c_str());
});
line = body.newLine(&grid);

// Alarms warning
new StaticText(line, rect_t{}, STR_ALARMWARNING, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.disableAlarmWarning));
new CheckBox(line, rect_t{},
GET_SET_INVERTED(g_eeGeneral.disableAlarmWarning));
line = body.newLine(&grid);

// RSSI shutdown alarm
new StaticText(line, rect_t{}, STR_RSSI_SHUTDOWN_ALARM, 0, COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{}, GET_SET_INVERTED(g_eeGeneral.disableRssiPoweroffAlarm));
new StaticText(line, rect_t{}, STR_RSSI_SHUTDOWN_ALARM, 0,
COLOR_THEME_PRIMARY1);
new CheckBox(line, rect_t{},
GET_SET_INVERTED(g_eeGeneral.disableRssiPoweroffAlarm));
line = body.newLine(&grid);

}
};

Expand Down
4 changes: 4 additions & 0 deletions radio/src/translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ ISTR(TEXT_SIZE);
ISTR(SUBTRIMMODES);
ISTR(PWR_OFF_DELAYS);

const char STR_MINUTE_SINGULAR[] = TR_MINUTE_SINGULAR;
const char STR_MINUTE_PLURAL1[] = TR_MINUTE_PLURAL1;
const char STR_MINUTE_PLURAL2[] = TR_MINUTE_PLURAL2;

const char STR_POPUPS_ENTER_EXIT[] = TR_POPUPS_ENTER_EXIT;
const char STR_OK[] = TR_OK;
const char STR_FREE[] = TR_FREE;
Expand Down
11 changes: 11 additions & 0 deletions radio/src/translations.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef _TRANSLATIONS_H_
#define _TRANSLATIONS_H_

#include <limits.h>
#include "opentx_types.h"
#include "translations/untranslated.h"

Expand Down Expand Up @@ -112,6 +113,16 @@
#define LCDW_128_480_LINEBREAK "\036"
#endif

constexpr int g_max_plural2 = TR_MAX_PLURAL2;
constexpr int g_min_plural2 = TR_MIN_PLURAL2;
constexpr int g_use_singular_in_plural = TR_USE_SINGULAR_IN_PLURAL;
constexpr int g_use_plural2_special_case = TR_USE_PLURAL2_SPECIAL_CASE;
constexpr int g_use_plural2 = TR_USE_PLURAL2;

extern const char STR_MINUTE_SINGULAR[];
extern const char STR_MINUTE_PLURAL1[];
extern const char STR_MINUTE_PLURAL2[];

extern const char* const STR_OFFON[];
extern const char* const STR_MMMINV[];
extern const char* const STR_VBEEPMODE[];
Expand Down
12 changes: 12 additions & 0 deletions radio/src/translations/cn.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "分钟"
#define TR_MINUTE_PLURAL1 "分钟"
#define TR_MINUTE_PLURAL2 "分钟"

#define TR_OFFON "禁用","开启"
#define TR_MMMINV "---","反\0"
Expand Down
13 changes: 13 additions & 0 deletions radio/src/translations/cz.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
* \001 to \034 -extended spacing (value * FW/2)
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 4
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 0
#define TR_USE_PLURAL2_SPECIAL_CASE 1
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 20

#define TR_MINUTE_SINGULAR "minuta"
#define TR_MINUTE_PLURAL1 "minuty"
#define TR_MINUTE_PLURAL2 "minut"

// NON ZERO TERMINATED STRINGS
#define TR_OFFON "VYP","ZAP"
#define TR_MMMINV "---","INV"
Expand Down
13 changes: 13 additions & 0 deletions radio/src/translations/da.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minut"
#define TR_MINUTE_PLURAL1 "minutter"
#define TR_MINUTE_PLURAL2 "minutter"

#define TR_OFFON "FRA","TIL"
#define TR_MMMINV "---","INV"
#define TR_VBEEPMODE "Stille","Alarm","NoKey","Alle"
Expand Down
13 changes: 13 additions & 0 deletions radio/src/translations/de.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minuten"
#define TR_MINUTE_PLURAL2 "minuten"

// NON ZERO TERMINATED STRINGS
#define TR_OFFON "AUS","EIN"
#define TR_MMMINV "---","INV"
Expand Down
11 changes: 11 additions & 0 deletions radio/src/translations/en.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in plural
#define TR_USE_SINGULAR_IN_PLURAL 0
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

#define TR_OFFON "OFF","ON"
#define TR_MMMINV "---","INV"
Expand Down
13 changes: 12 additions & 1 deletion radio/src/translations/es.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@
* \0 -ends current string
*/


#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

#define TR_OFFON "OFF","ON"
#define TR_MMMINV "---","INV"
Expand Down
13 changes: 13 additions & 0 deletions radio/src/translations/fi.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

// NON ZERO TERMINATED STRINGS
#define TR_OFFON "POI","PÄÄ"
#define TR_MMMINV "---","KÄÄ"
Expand Down
12 changes: 12 additions & 0 deletions radio/src/translations/fr.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

// NON ZERO TERMINATED STRINGS
#define TR_OFFON "OFF","ON"
Expand Down
12 changes: 12 additions & 0 deletions radio/src/translations/it.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minuto"
#define TR_MINUTE_PLURAL1 "minuti"
#define TR_MINUTE_PLURAL2 "minuti"

#define TR_OFFON TR("OFF","Disattivato"),TR("ON","Attivato")
#define TR_MMMINV "---","INV"
Expand Down
12 changes: 12 additions & 0 deletions radio/src/translations/jp.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

#define TR_OFFON "OFF","ON"
#define TR_MMMINV "---","リバース"
Expand Down
13 changes: 12 additions & 1 deletion radio/src/translations/nl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@
* \0 -ends current string
*/


#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

#define TR_OFFON "UIT","AAN"
#define TR_MMMINV "---","INV"
Expand Down
12 changes: 12 additions & 0 deletions radio/src/translations/pl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 4
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 0
#define TR_USE_PLURAL2_SPECIAL_CASE 1
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minuta"
#define TR_MINUTE_PLURAL1 "minuty"
#define TR_MINUTE_PLURAL2 "minut"

#define TR_OFFON "WYŁ","ZAŁ"
#define TR_MMMINV "---","REV"
Expand Down
13 changes: 13 additions & 0 deletions radio/src/translations/pt.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minute"
#define TR_MINUTE_PLURAL1 "minutes"
#define TR_MINUTE_PLURAL2 "minutes"

#define TR_OFFON "OFF","ON"
#define TR_MMMINV "---","INV"
#define TR_VBEEPMODE "Mudo","Alarm","NoKey","Todo"
Expand Down
13 changes: 13 additions & 0 deletions radio/src/translations/se.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "minut"
#define TR_MINUTE_PLURAL1 "minuter"
#define TR_MINUTE_PLURAL2 "minuter"

// NON ZERO TERMINATED STRINGS
#define TR_OFFON "Av","På"
#define TR_MMMINV "---","INV"
Expand Down
12 changes: 12 additions & 0 deletions radio/src/translations/tw.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
* \0 -ends current string
*/

#define TR_MIN_PLURAL2 2
#define TR_MAX_PLURAL2 2
// For this number of minute in the last decimal place singular form is used in
// plural
#define TR_USE_SINGULAR_IN_PLURAL 1
#define TR_USE_PLURAL2_SPECIAL_CASE 0
// If the number of minutes is above this value PLURAL2 is used
#define TR_USE_PLURAL2 INT_MAX

#define TR_MINUTE_SINGULAR "分鐘"
#define TR_MINUTE_PLURAL1 "分鐘"
#define TR_MINUTE_PLURAL2 "分鐘"

#define TR_OFFON "禁用","開啟"
#define TR_MMMINV "---","反"
Expand Down

0 comments on commit 15dca01

Please sign in to comment.