Add localized message for logged-in user count in German and English, enhancing user interface clarity. Update widget creation in app.cpp to utilize translation for various UI elements, improving localization consistency.

This commit is contained in:
Torsten Schulz (local)
2025-11-16 21:39:02 +01:00
parent a18c09592d
commit 8f24425110
12 changed files with 21 additions and 10 deletions

View File

@@ -428,7 +428,7 @@ void App::updateUserlist(Wt::Json::Array unsortedUserList, int size) {
layout->setContentsMargins(0, 0, 0, 0);
userListContainer_->setOverflow(Wt::Overflow::Auto, Wt::Orientation::Vertical);
userListContainer_->setOverflow(Wt::Overflow::Hidden, Wt::Orientation::Horizontal);
layout->addWidget(std::make_unique<Wt::WText>(Wt::WString("Logged in: {1}").arg(size)));
layout->addWidget(std::make_unique<Wt::WText>(Wt::WString::tr("logged_in_count").arg(size)));
auto sortedUserList = sortUserList(unsortedUserList);
for (Wt::Json::Object &user: sortedUserList) {
addUserItemToLayout(layout, user);
@@ -1205,16 +1205,16 @@ Wt::WVBoxLayout *App::resetSearchFields() {
contentContainer_->clear();
inboxOpen_ = false;
auto contentLayout = contentContainer_->setLayout(std::make_unique<Wt::WVBoxLayout>());
contentLayout->addWidget(std::make_unique<Wt::WText>("<h2>Search</h2>"));
contentLayout->addWidget(std::make_unique<Wt::WText>(Wt::WString::tr("search_title"), Wt::TextFormat::UnsafeXHTML));
return contentLayout;
}
std::pair<Wt::WSpinBox*, Wt::WSpinBox*> App::setupSearchFields(Wt::WVBoxLayout *contentLayout) {
auto minAgeEdit = addSearchItemLine<Wt::WSpinBox>(contentLayout, "From age");
auto minAgeEdit = addSearchItemLine<Wt::WSpinBox>(contentLayout, Wt::WString::tr("search_from_age").toUTF8());
minAgeEdit->setRange(18, 150);
minAgeEdit->setValue(18);
minAgeEdit->changed().connect([=, this] { searchFields.minAge = minAgeEdit->value(); });
auto maxAgeEdit = addSearchItemLine<Wt::WSpinBox>(contentLayout, "To age");
auto maxAgeEdit = addSearchItemLine<Wt::WSpinBox>(contentLayout, Wt::WString::tr("search_to_age").toUTF8());
maxAgeEdit->setRange(18, 150);
maxAgeEdit->setValue(150);
maxAgeEdit->changed().connect([=, this] { searchFields.maxAge = maxAgeEdit->value(); });
@@ -1222,12 +1222,12 @@ std::pair<Wt::WSpinBox*, Wt::WSpinBox*> App::setupSearchFields(Wt::WVBoxLayout *
}
std::pair<Wt::WContainerWidget*, Wt::WContainerWidget*> App::setupCountryDropDown(Wt::WVBoxLayout *contentLayout) {
auto countryOpenList = addSearchItemLine<Wt::WContainerWidget>(contentLayout, "Country");
countryOpenList->addNew<Wt::WText>("All");
auto countryOpenList = addSearchItemLine<Wt::WContainerWidget>(contentLayout, Wt::WString::tr("search_country").toUTF8());
countryOpenList->addNew<Wt::WText>(Wt::WString::tr("search_all"));
countryOpenList->setStyleClass("selectBoxes-drop-down-trigger");
auto countryDropDown = countryOpenList->addNew<Wt::WContainerWidget>();
countryDropDown->setStyleClass("selectBoxes-dropdown");
countryOpenList->setToolTip("Select the countries you'll search for");
countryOpenList->setToolTip(Wt::WString::tr("search_country_tooltip"));
std::map<Wt::WString, Wt::WString> countries = server_.countries();
addItem("All", countryDropDown, countryOpenList, &searchFields.countries, true);
addItem(country, countryDropDown, countryOpenList, &searchFields.countries);
@@ -1240,12 +1240,12 @@ std::pair<Wt::WContainerWidget*, Wt::WContainerWidget*> App::setupCountryDropDow
}
std::pair<Wt::WContainerWidget*, Wt::WContainerWidget*> App::setupGendersDropDown(Wt::WVBoxLayout *contentLayout) {
auto gendersOpenList = addSearchItemLine<Wt::WContainerWidget>(contentLayout, "Genders");
gendersOpenList->addNew<Wt::WText>("All");
auto gendersOpenList = addSearchItemLine<Wt::WContainerWidget>(contentLayout, Wt::WString::tr("search_genders").toUTF8());
gendersOpenList->addNew<Wt::WText>(Wt::WString::tr("search_all"));
gendersOpenList->setStyleClass("selectBoxes-drop-down-trigger");
auto gendersDropDown = gendersOpenList->addNew<Wt::WContainerWidget>();
gendersDropDown->setStyleClass("selectBoxes-dropdown");
gendersOpenList->setToolTip("Select the genders you'll search for");
gendersOpenList->setToolTip(Wt::WString::tr("search_genders_tooltip"));
addItem("All", gendersDropDown, gendersOpenList, &searchFields.gender, true);
std::map<Wt::WString, Wt::WString> swappedGenders;
for (const auto& pair : genders_) {