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

@ -2762,16 +2762,10 @@ options: %d
опции: %d
[ORIGINAL]
analyzed: yes
analyzed: %s
[TRANSLATED]
проанализировано: да
[ORIGINAL]
analyzed: no
[TRANSLATED]
проанализировано: нет
проанализировано: %s
[ORIGINAL]
extensions:
@ -2826,3 +2820,15 @@ You're launched standalone version of %s. Metamod is not installed or not enable
[TRANSLATED]
Вы запустили автономную версию %s. Metamod не установлен или не включён!
[ORIGINAL]
yes
[TRANSLATED]
да
[ORIGINAL]
no
[TRANSLATED]
нет

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 ();
}
}

View file

@ -1274,7 +1274,7 @@ void BotGraph::showFileInfo () {
msg (" compressed_size: %dkB", m_graphHeader.compressed / 1024);
msg (" uncompressed_size: %dkB", m_graphHeader.uncompressed / 1024);
msg (" options: %d", m_graphHeader.options); // display as string ?
msg (" analyzed: %s", isAnalyzed () ? "yes" : "no"); // display as string ?
msg (" analyzed: %s", isAnalyzed () ? conf.translate ("yes") : conf.translate ("no")); // display as string ?
msg ("");