Translate Device Name #872

This commit is contained in:
Proddy
2023-01-03 14:50:50 +01:00
parent 9a09062a84
commit 5005d06507
16 changed files with 146 additions and 90 deletions

View File

@@ -187,9 +187,10 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) {
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice->has_entities()) {
JsonObject obj = devices.createNestedObject();
obj["i"] = emsdevice->unique_id(); // its unique id
obj["s"] = emsdevice->device_type_name() + " (" + emsdevice->name() + ")"; // shortname
obj["t"] = Helpers::toLower(emsdevice->device_type_name());
obj["i"] = emsdevice->unique_id(); // its unique id
obj["s"] = std::string(emsdevice->device_type_2_device_name_translated()) + " (" + emsdevice->name() + ")"; // shortname, is device type translated
obj["tn"] = emsdevice->device_type_name(); // non-translated, lower-case
obj["t"] = emsdevice->device_type(); // internal device type ID
}
}

View File

@@ -81,7 +81,8 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER || emsdevice->count_entities() > 0)) {
JsonObject obj = devices.createNestedObject();
obj["id"] = Helpers::smallitoa(buffer, emsdevice->unique_id()); // a unique id as a string
obj["t"] = emsdevice->device_type_name(); // type
obj["tn"] = emsdevice->device_type_2_device_name_translated(); // translated device type name
obj["t"] = emsdevice->device_type(); // device type number
obj["b"] = emsdevice->brand_to_string(); // brand
obj["n"] = emsdevice->name(); // name
obj["d"] = emsdevice->device_id(); // deviceid

View File

@@ -240,10 +240,12 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
String old_local = settings.locale;
settings.locale = root["locale"] | EMSESP_DEFAULT_LOCALE;
check_flag(prev, settings.low_clock, ChangeFlags::RESTART);
EMSESP::system_.locale(settings.locale);
#ifndef EMSESP_STANDALONE
if (!old_local.equals(settings.locale)) {
add_flags(ChangeFlags::MQTT);
add_flags(ChangeFlags::RESTART); // force restart
// add_flags(ChangeFlags::MQTT);
}
#endif