mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
fix REST-API - strange characters in http://<hostname>/api/<device>/commands output #671
This commit is contained in:
@@ -719,4 +719,21 @@ std::string Helpers::translated_word(const char * const * strings, bool to_lower
|
||||
return to_lower ? toLower((strings[index])) : (strings[index]);
|
||||
}
|
||||
|
||||
// returns char pointer to translated description or fullname
|
||||
const char * Helpers::translated_fullname(const char * const * strings) {
|
||||
uint8_t language_index = EMSESP::system_.language_index();
|
||||
uint8_t index = 0;
|
||||
|
||||
// check for empty
|
||||
if (!strings) {
|
||||
return nullptr; // it's a nullptr with no translations, return empty to prevent unwanted crash
|
||||
}
|
||||
|
||||
// see how many translations we have for this entity. if there is no translation for this, revert to EN
|
||||
if (Helpers::count_items(strings) >= language_index + 1 && strlen(strings[language_index])) {
|
||||
index = language_index;
|
||||
}
|
||||
return strings[index];
|
||||
}
|
||||
|
||||
} // namespace emsesp
|
||||
|
||||
Reference in New Issue
Block a user