diff --git a/i18n/i18n.h b/i18n/i18n.h index 2a52b21043..ffa09647aa 100644 --- a/i18n/i18n.h +++ b/i18n/i18n.h @@ -37,6 +37,9 @@ class I18NCategory { public: I18NCategory(const char *name) : name_(name) {} const char *T(const char *key, const char *def = 0); + const char *T(const std::string &key) { + return T(key.c_str(), nullptr); + } const std::map &Missed() const { return missedKeyLog_; diff --git a/ui/ui_screen.cpp b/ui/ui_screen.cpp index fb53a3a489..a6de1bebb5 100644 --- a/ui/ui_screen.cpp +++ b/ui/ui_screen.cpp @@ -458,7 +458,10 @@ void ChoiceWithValueDisplay::Draw(UIContext &dc) { dc.SetFontStyle(dc.theme->uiFont); if (sValue_ != nullptr) { - valueText << *sValue_; + if (category_) + valueText << category_->T(*sValue_); + else + valueText << *sValue_; } else if (iValue_ != nullptr) { valueText << *iValue_; } diff --git a/ui/ui_screen.h b/ui/ui_screen.h index 82b519c701..f536397601 100644 --- a/ui/ui_screen.h +++ b/ui/ui_screen.h @@ -271,16 +271,17 @@ private: class ChoiceWithValueDisplay : public UI::Choice { public: ChoiceWithValueDisplay(int *value, const std::string &text, LayoutParams *layoutParams = 0) - : Choice(text, layoutParams), iValue_(value) { sValue_ = nullptr; } + : Choice(text, layoutParams), iValue_(value), category_(nullptr) { sValue_ = nullptr; } - ChoiceWithValueDisplay(std::string *value, const std::string &text, LayoutParams *layoutParams = 0) - : Choice(text, layoutParams), sValue_(value) { iValue_ = nullptr; } + ChoiceWithValueDisplay(std::string *value, const std::string &text, I18NCategory *category, LayoutParams *layoutParams = 0) + : Choice(text, layoutParams), sValue_(value), category_(category) { iValue_ = nullptr; } void Draw(UIContext &dc); private: int *iValue_; std::string *sValue_; + I18NCategory *category_; }; } // namespace UI