From 45c029cd7cbf502d90294c3d2aae147e8e935976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 22 Jan 2026 01:30:38 +0100 Subject: [PATCH] Fix issue with missing strings in I18n.cpp --- Common/Data/Text/I18n.cpp | 37 ++++++++++++++++++------------------- Common/Data/Text/I18n.h | 4 ++-- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Common/Data/Text/I18n.cpp b/Common/Data/Text/I18n.cpp index c909ad3af7..37d0e86e76 100644 --- a/Common/Data/Text/I18n.cpp +++ b/Common/Data/Text/I18n.cpp @@ -85,15 +85,14 @@ std::string_view I18NCategory::T(std::string_view key, std::string_view def) { if (key != "Font") { // Font is allowed to be missing. INFO_LOG(Log::UI, "Missing translation [%s] %.*s (%.*s)", name_.c_str(), STR_VIEW(key), STR_VIEW(def)); + std::lock_guard guard(missedKeyLock_); + std::string missedKey(key); + if (!def.empty()) + missedKeyLog_[missedKey] = def; + else + missedKeyLog_[missedKey] = missedKey; + return !def.empty() ? def : key; } - - std::lock_guard guard(missedKeyLock_); - std::string missedKey(key); - if (!def.empty()) - missedKeyLog_[missedKey] = def; - else - missedKeyLog_[missedKey] = missedKey; - return !def.empty() ? def : key; } } @@ -106,17 +105,17 @@ const char *I18NCategory::T_cstr(const char *key, const char *def) { // Too early. This is probably in desktop-ui translation. return def ? def : key; } - if (key != "Font") { - INFO_LOG(Log::UI, "Missing translation %s (%s)", key, def); - } - - std::lock_guard guard(missedKeyLock_); std::string missedKey(key); - if (def) - missedKeyLog_[missedKey] = def; - else - missedKeyLog_[missedKey] = std::string(key); - return def ? def : key; + if (missedKey != "Font") { + INFO_LOG(Log::UI, "Missing translation %s (%s)", key, def); + + std::lock_guard guard(missedKeyLock_); + if (def) + missedKeyLog_[missedKey] = def; + else + missedKeyLog_[missedKey] = std::string(key); + return def ? def : key; + } } } @@ -130,7 +129,7 @@ void I18NCategory::SetMap(const std::map &m) { } } -std::map I18NCategory::Missed() const { +std::map> I18NCategory::Missed() const { std::lock_guard guard(missedKeyLock_); return missedKeyLog_; } diff --git a/Common/Data/Text/I18n.h b/Common/Data/Text/I18n.h index 9ab1d39154..9d1c98045f 100644 --- a/Common/Data/Text/I18n.h +++ b/Common/Data/Text/I18n.h @@ -81,7 +81,7 @@ public: // Try to avoid this. Still useful in snprintf. const char *T_cstr(const char *key, const char *def = nullptr); - std::map Missed() const; + std::map> Missed() const; const std::map> &GetMap() { return map_; } void ClearMissed() { missedKeyLog_.clear(); } @@ -94,7 +94,7 @@ private: // std::less<> is needed to be able to look up string_views in a string-keyed map. std::map> map_; mutable std::mutex missedKeyLock_; - std::map missedKeyLog_; + std::map> missedKeyLog_; std::string name_; // Noone else can create these.