diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index 288e1496a..44493a116 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -164,7 +164,11 @@ void GroupChatForm::onSendTriggered() void GroupChatForm::onUserListChanged() { - nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(group->getPeersCount())); + int peersCount = group->getPeersCount(); + if (peersCount == 1) + nusersLabel->setText(tr("1 user in chat", "Number of users in chat")); + else + nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(peersCount)); QLayoutItem *child; while ((child = namesListLayout->takeAt(0))) @@ -204,7 +208,7 @@ void GroupChatForm::onUserListChanged() } // Enable or disable call button - if (group->getPeersCount() != 1) + if (peersCount != 1) { callButton->setEnabled(true); callButton->setObjectName("green"); @@ -367,5 +371,9 @@ void GroupChatForm::keyReleaseEvent(QKeyEvent* ev) void GroupChatForm::retranslateUi() { - nusersLabel->setText(GroupChatForm::tr("%1 users in chat", "Number of users in chat").arg(group->getPeersCount())); + int peersCount = group->getPeersCount(); + if (peersCount == 1) + nusersLabel->setText(tr("1 user in chat", "Number of users in chat")); + else + nusersLabel->setText(tr("%1 users in chat", "Number of users in chat").arg(peersCount)); } diff --git a/src/widget/groupwidget.cpp b/src/widget/groupwidget.cpp index b7993b5a1..a13ea8816 100644 --- a/src/widget/groupwidget.cpp +++ b/src/widget/groupwidget.cpp @@ -27,6 +27,7 @@ #include "src/widget/style.h" #include "src/core/core.h" #include "tool/croppinglabel.h" +#include "src/widget/translator.h" #include #include #include @@ -56,6 +57,7 @@ GroupWidget::GroupWidget(int GroupId, QString Name) emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128)); } }); + Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this); } void GroupWidget::contextMenuEvent(QContextMenuEvent* event) @@ -82,7 +84,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event) menu.addSeparator(); QAction* setTitle = menu.addAction(tr("Set title...")); - QAction* quitGroup = menu.addAction(tr("Quit group","Menu to quit a groupchat")); + QAction* quitGroup = menu.addAction(tr("Quit group", "Menu to quit a groupchat")); QAction* selectedItem = menu.exec(event->globalPos()); @@ -145,9 +147,13 @@ void GroupWidget::onUserListChanged() { Group* g = GroupList::findGroup(groupId); if (g) - statusMessageLabel->setText(tr("%1 users in chat").arg(g->getPeersCount())); - else - statusMessageLabel->setText(tr("0 users in chat")); + { + int peersCount = g->getPeersCount(); + if (peersCount == 1) + statusMessageLabel->setText(tr("1 user in chat")); + else + statusMessageLabel->setText(tr("%1 users in chat").arg(peersCount)); + } } void GroupWidget::setAsActiveChatroom() @@ -249,3 +255,16 @@ void GroupWidget::setName(const QString& name) { nameLabel->setText(name); } + +void GroupWidget::retranslateUi() +{ + Group* g = GroupList::findGroup(groupId); + if (g) + { + int peersCount = g->getPeersCount(); + if (peersCount == 1) + statusMessageLabel->setText(tr("1 user in chat")); + else + statusMessageLabel->setText(tr("%1 users in chat").arg(peersCount)); + } +} diff --git a/src/widget/groupwidget.h b/src/widget/groupwidget.h index 68f7b6f64..71e535c58 100644 --- a/src/widget/groupwidget.h +++ b/src/widget/groupwidget.h @@ -52,6 +52,9 @@ protected: void dragLeaveEvent(QDragLeaveEvent* ev) override; void dropEvent(QDropEvent* ev) override; +private: + void retranslateUi(); + public: int groupId; };