diff --git a/radio/src/gui/colorlcd/radio_setup.cpp b/radio/src/gui/colorlcd/radio_setup.cpp index 30759ca7612..d5d0f55d639 100644 --- a/radio/src/gui/colorlcd/radio_setup.cpp +++ b/radio/src/gui/colorlcd/radio_setup.cpp @@ -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); - } }; diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 62f810000d2..940aa626c78 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -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; diff --git a/radio/src/translations.h b/radio/src/translations.h index 989386db4af..3d3d7fc3d88 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -22,6 +22,7 @@ #ifndef _TRANSLATIONS_H_ #define _TRANSLATIONS_H_ +#include #include "opentx_types.h" #include "translations/untranslated.h" @@ -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[]; diff --git a/radio/src/translations/cn.h b/radio/src/translations/cn.h index 004b4b75305..cd8934ea127 100644 --- a/radio/src/translations/cn.h +++ b/radio/src/translations/cn.h @@ -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" diff --git a/radio/src/translations/cz.h b/radio/src/translations/cz.h index 7020c24aeeb..d8ed8975c3f 100644 --- a/radio/src/translations/cz.h +++ b/radio/src/translations/cz.h @@ -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" diff --git a/radio/src/translations/da.h b/radio/src/translations/da.h index 1452a5b5b41..426bae4f1ad 100644 --- a/radio/src/translations/da.h +++ b/radio/src/translations/da.h @@ -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" diff --git a/radio/src/translations/de.h b/radio/src/translations/de.h index 5126f6d1d48..1d85221886c 100644 --- a/radio/src/translations/de.h +++ b/radio/src/translations/de.h @@ -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" diff --git a/radio/src/translations/en.h b/radio/src/translations/en.h index 5f0c98d2d49..0dcc437f733 100644 --- a/radio/src/translations/en.h +++ b/radio/src/translations/en.h @@ -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" diff --git a/radio/src/translations/es.h b/radio/src/translations/es.h index ebb7e6692ce..ad33d09e7f7 100644 --- a/radio/src/translations/es.h +++ b/radio/src/translations/es.h @@ -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" diff --git a/radio/src/translations/fi.h b/radio/src/translations/fi.h index 77375cc6fae..b193987af48 100644 --- a/radio/src/translations/fi.h +++ b/radio/src/translations/fi.h @@ -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ÄÄ" diff --git a/radio/src/translations/fr.h b/radio/src/translations/fr.h index 853a2342b70..dab81d65371 100644 --- a/radio/src/translations/fr.h +++ b/radio/src/translations/fr.h @@ -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" diff --git a/radio/src/translations/it.h b/radio/src/translations/it.h index f62fb7c245a..7d30c78bb10 100644 --- a/radio/src/translations/it.h +++ b/radio/src/translations/it.h @@ -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" diff --git a/radio/src/translations/jp.h b/radio/src/translations/jp.h index 1466fd1b18e..5d12a1ff071 100644 --- a/radio/src/translations/jp.h +++ b/radio/src/translations/jp.h @@ -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 "---","リバース" diff --git a/radio/src/translations/nl.h b/radio/src/translations/nl.h index bfaa306467b..6a6615af9d8 100644 --- a/radio/src/translations/nl.h +++ b/radio/src/translations/nl.h @@ -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" diff --git a/radio/src/translations/pl.h b/radio/src/translations/pl.h index fbae86230c7..40a2132443c 100644 --- a/radio/src/translations/pl.h +++ b/radio/src/translations/pl.h @@ -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" diff --git a/radio/src/translations/pt.h b/radio/src/translations/pt.h index 054cec67189..5298525259e 100644 --- a/radio/src/translations/pt.h +++ b/radio/src/translations/pt.h @@ -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" diff --git a/radio/src/translations/se.h b/radio/src/translations/se.h index ed7515c475e..210e71886de 100644 --- a/radio/src/translations/se.h +++ b/radio/src/translations/se.h @@ -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" diff --git a/radio/src/translations/tw.h b/radio/src/translations/tw.h index e963aea8257..7b8eb74b199 100644 --- a/radio/src/translations/tw.h +++ b/radio/src/translations/tw.h @@ -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 "---","反"