support localization for grid usage in display
This commit is contained in:
parent
4f6f0fd101
commit
d9177dad34
@ -80,6 +80,8 @@ private:
|
||||
String _i18n_date_format;
|
||||
String _i18n_current_power_kw;
|
||||
String _i18n_current_power_w;
|
||||
String _i18n_meter_power_w;
|
||||
String _i18n_meter_power_kw;
|
||||
String _i18n_yield_total_mwh;
|
||||
String _i18n_yield_total_kwh;
|
||||
};
|
||||
|
||||
@ -22,6 +22,7 @@ public:
|
||||
String& date_format,
|
||||
String& offline,
|
||||
String& power_w, String& power_kw,
|
||||
String& meter_power_w, String& meter_power_kw,
|
||||
String& yield_today_wh, String& yield_today_kwh,
|
||||
String& yield_total_kwh, String& yield_total_mwh);
|
||||
|
||||
|
||||
@ -179,6 +179,8 @@ void DisplayGraphicClass::setLocale(const String& locale)
|
||||
_i18n_offline = i18n_offline[idx];
|
||||
_i18n_current_power_w = i18n_current_power_w[idx];
|
||||
_i18n_current_power_kw = i18n_current_power_kw[idx];
|
||||
_i18n_meter_power_w = i18n_meter_power_w[idx];
|
||||
_i18n_meter_power_kw = i18n_meter_power_kw[idx];
|
||||
_i18n_yield_today_wh = i18n_yield_today_wh[idx];
|
||||
_i18n_yield_today_kwh = i18n_yield_today_kwh[idx];
|
||||
_i18n_yield_total_kwh = i18n_yield_total_kwh[idx];
|
||||
@ -189,6 +191,8 @@ void DisplayGraphicClass::setLocale(const String& locale)
|
||||
_i18n_offline,
|
||||
_i18n_current_power_w,
|
||||
_i18n_current_power_kw,
|
||||
_i18n_meter_power_w,
|
||||
_i18n_meter_power_kw,
|
||||
_i18n_yield_today_wh,
|
||||
_i18n_yield_today_kwh,
|
||||
_i18n_yield_total_kwh,
|
||||
@ -315,9 +319,9 @@ void DisplayGraphicClass::loop()
|
||||
|
||||
auto acPower = PowerMeter.getPowerTotal();
|
||||
if (acPower > 999) {
|
||||
snprintf(_fmtText, sizeof(_fmtText), i18n_meter_power_kw[_display_language], (acPower / 1000));
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_meter_power_kw.c_str(), (acPower / 1000));
|
||||
} else {
|
||||
snprintf(_fmtText, sizeof(_fmtText), i18n_meter_power_w[_display_language], acPower);
|
||||
snprintf(_fmtText, sizeof(_fmtText), _i18n_meter_power_w.c_str(), acPower);
|
||||
}
|
||||
|
||||
printText(_fmtText, 2);
|
||||
|
||||
@ -43,6 +43,7 @@ void I18nClass::readDisplayStrings(
|
||||
String& date_format,
|
||||
String& offline,
|
||||
String& power_w, String& power_kw,
|
||||
String& meter_power_w, String& meter_power_kw,
|
||||
String& yield_today_wh, String& yield_today_kwh,
|
||||
String& yield_total_kwh, String& yield_total_mwh)
|
||||
{
|
||||
@ -88,6 +89,14 @@ void I18nClass::readDisplayStrings(
|
||||
power_kw = displayData["power_kw"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["meter_power_w"].as<String>() != "null") {
|
||||
meter_power_w = displayData["meter_power_w"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["meter_power_kw"].as<String>() != "null") {
|
||||
meter_power_kw = displayData["meter_power_kw"].as<String>();
|
||||
}
|
||||
|
||||
if (displayData["yield_today_wh"].as<String>() != "null") {
|
||||
yield_today_wh = displayData["yield_today_wh"].as<String>();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user