fix: eating whitespaces in translations (resolves #372)

Co-Authored-By: Max <161382234+dyspose@users.noreply.github.com>
This commit is contained in:
jeefo 2024-05-15 23:57:23 +03:00
commit 33aaf950e2
No known key found for this signature in database
GPG key ID: D696786B81B667C8
3 changed files with 30 additions and 20 deletions

View file

@ -482,8 +482,12 @@ void BotConfig::loadLanguageConfig () {
String temp;
Twin <String, String> lang;
auto trimWithoutWs = [] (String in) -> String {
return in.trim ("\r\n");
};
auto pushTranslatedMsg = [&] () {
m_language[hashLangString (lang.first.trim ().chars ())] = lang.second.trim ();
m_language[hashLangString (trimWithoutWs (lang.first).chars ())] = trimWithoutWs (lang.second);
};
// clear all the translations before new load
@ -512,7 +516,7 @@ void BotConfig::loadLanguageConfig () {
// make sure last string is translated
if (file.eof () && !lang.first.empty ()) {
lang.second = line.trim ();
lang.second = trimWithoutWs (line);
pushTranslatedMsg ();
}
}