summaryrefslogtreecommitdiff
path: root/protocols/Weather/src/weather_update.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-01-27 13:10:19 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-01-27 13:10:19 +0300
commit34e7e0e28b05095193d672b45d79d0ded38bb8f4 (patch)
tree45b98cdc7f9b084ac77f2f9cc7b9a803b42c9d90 /protocols/Weather/src/weather_update.cpp
parentb30bfbd03fef42287cad703411929071bc8387b9 (diff)
fixes #4847 (Weather: переводить строки перед склеиванием)
Diffstat (limited to 'protocols/Weather/src/weather_update.cpp')
-rw-r--r--protocols/Weather/src/weather_update.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp
index a03e0aeeca..2af9dc3cc8 100644
--- a/protocols/Weather/src/weather_update.cpp
+++ b/protocols/Weather/src/weather_update.cpp
@@ -360,9 +360,26 @@ static wchar_t *moon2str(double phase)
return TranslateT("Waning crescent");
}
+static CMStringW parseConditions(const CMStringW &str)
+{
+ CMStringW ret;
+ int iStart = 0;
+ while (true) {
+ auto substr = str.Tokenize(L",", iStart);
+ if (substr.IsEmpty())
+ break;
+
+ substr.Trim();
+ if (!ret.IsEmpty())
+ ret += ", ";
+ ret += TranslateW(substr);
+ }
+ return ret;
+}
+
static void getData(OBJLIST<WIDATAITEM> &arValues, const JSONNode &node)
{
- arValues.insert(new WIDATAITEM(LPGENW("Condition"), L"", node["conditions"].as_mstring()));
+ arValues.insert(new WIDATAITEM(LPGENW("Condition"), L"", parseConditions(node["conditions"].as_mstring())));
arValues.insert(new WIDATAITEM(LPGENW("Temperature"), L"C", node["temp"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("High"), L"C", node["tempmax"].as_mstring()));
arValues.insert(new WIDATAITEM(LPGENW("Low"), L"C", node["tempmin"].as_mstring()));