client, QWidget *parent)
username_input_ = new TextField();
username_input_->setTextColor("#333333");
- username_input_->setLabel("Username");
+ username_input_->setLabel(tr("Username"));
username_input_->setInkColor("#555459");
username_input_->setBackgroundColor("#f9f9f9");
password_input_ = new TextField();
password_input_->setTextColor("#333333");
- password_input_->setLabel("Password");
+ password_input_->setLabel(tr("Password"));
password_input_->setInkColor("#555459");
password_input_->setBackgroundColor("#f9f9f9");
password_input_->setEchoMode(QLineEdit::Password);
password_confirmation_ = new TextField();
password_confirmation_->setTextColor("#333333");
- password_confirmation_->setLabel("Password confirmation");
+ password_confirmation_->setLabel(tr("Password confirmation"));
password_confirmation_->setInkColor("#555459");
password_confirmation_->setBackgroundColor("#f9f9f9");
password_confirmation_->setEchoMode(QLineEdit::Password);
server_input_ = new TextField();
server_input_->setTextColor("#333333");
- server_input_->setLabel("Home Server");
+ server_input_->setLabel(tr("Home Server"));
server_input_->setInkColor("#555459");
server_input_->setBackgroundColor("#f9f9f9");
@@ -105,7 +105,7 @@ RegisterPage::RegisterPage(QSharedPointer client, QWidget *parent)
error_label_ = new QLabel(this);
error_label_->setStyleSheet("margin-bottom: 10px; color: #E22826; font-size: 11pt;");
- register_button_ = new RaisedButton("REGISTER", this);
+ register_button_ = new RaisedButton(tr("REGISTER"), this);
register_button_->setBackgroundColor(QColor("#333333"));
register_button_->setForegroundColor(QColor("white"));
register_button_->setMinimumSize(350, 65);
@@ -156,13 +156,13 @@ void RegisterPage::onRegisterButtonClicked()
error_label_->setText("");
if (!username_input_->hasAcceptableInput()) {
- registerError("Invalid username");
+ registerError(tr("Invalid username"));
} else if (!password_input_->hasAcceptableInput()) {
- registerError("Password is not long enough (min 8 chars)");
+ registerError(tr("Password is not long enough (min 8 chars)"));
} else if (password_input_->text() != password_confirmation_->text()) {
- registerError("Passwords don't match");
+ registerError(tr("Passwords don't match"));
} else if (!server_input_->hasAcceptableInput()) {
- registerError("Invalid server name");
+ registerError(tr("Invalid server name"));
} else {
QString username = username_input_->text();
QString password = password_input_->text();
diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc
index ab73a98f..cda00c2c 100644
--- a/src/TextInputWidget.cc
+++ b/src/TextInputWidget.cc
@@ -59,7 +59,7 @@ TextInputWidget::TextInputWidget(QWidget *parent)
input_ = new FilteredTextEdit(this);
input_->setFixedHeight(45);
- input_->setPlaceholderText("Write a message...");
+ input_->setPlaceholderText(tr("Write a message..."));
input_->setStyleSheet("color: #333333; font-size: 13px; border-radius: 0; padding-top: 10px;");
send_message_button_ = new FlatButton(this);
diff --git a/src/TrayIcon.cc b/src/TrayIcon.cc
index 3a227087..beaf00df 100644
--- a/src/TrayIcon.cc
+++ b/src/TrayIcon.cc
@@ -70,8 +70,8 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
setIcon(QIcon(icon_));
QMenu *menu = new QMenu(parent);
- viewAction_ = new QAction("Show", parent);
- quitAction_ = new QAction("Quit", parent);
+ viewAction_ = new QAction(tr("Show"), parent);
+ quitAction_ = new QAction(tr("Quit"), parent);
connect(viewAction_, SIGNAL(triggered()), parent, SLOT(show()));
connect(quitAction_, &QAction::triggered, this, [=]() {
diff --git a/src/WelcomePage.cc b/src/WelcomePage.cc
index d6668e7b..b88c4db1 100644
--- a/src/WelcomePage.cc
+++ b/src/WelcomePage.cc
@@ -34,21 +34,18 @@ WelcomePage::WelcomePage(QWidget *parent)
intro_banner_->setAlignment(Qt::AlignCenter);
intro_text_ = new QLabel(this);
- intro_text_->setText(QApplication::translate("WelcomePage",
- ""
- ""
- ""
- " "
- " "
- " Welcome to nheko! The desktop client for the Matrix protocol."
- " "
- "
\n"
- " "
- " Enjoy your stay!"
- "
"
- ""
- "",
- Q_NULLPTR));
+
+ QString heading(tr("Welcome to nheko! The desktop client for the Matrix protocol."));
+ QString main(tr("Enjoy your stay!"));
+
+ intro_text_->setText(QString(""
+ " %1 "
+ "
"
+ ""
+ " %2 "
+ "
")
+ .arg(heading)
+ .arg(main));
top_layout_->addStretch(1);
top_layout_->addWidget(intro_banner_);
@@ -60,7 +57,7 @@ WelcomePage::WelcomePage(QWidget *parent)
button_layout_->setSpacing(0);
button_layout_->setContentsMargins(0, 20, 0, 80);
- register_button_ = new RaisedButton("REGISTER", this);
+ register_button_ = new RaisedButton(tr("REGISTER"), this);
register_button_->setBackgroundColor(QColor("#333333"));
register_button_->setForegroundColor(QColor("white"));
register_button_->setMinimumSize(240, 60);
@@ -68,7 +65,7 @@ WelcomePage::WelcomePage(QWidget *parent)
register_button_->setFontSize(14);
register_button_->setCornerRadius(3);
- login_button_ = new RaisedButton("LOGIN", this);
+ login_button_ = new RaisedButton(tr("LOGIN"), this);
login_button_->setBackgroundColor(QColor("#333333"));
login_button_->setForegroundColor(QColor("white"));
login_button_->setMinimumSize(240, 60);
diff --git a/src/main.cc b/src/main.cc
index 993eea82..e6d4c4e7 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -18,6 +18,8 @@
#include
#include
#include
+#include
+#include
#include "MainWindow.h"
@@ -44,6 +46,16 @@ int main(int argc, char *argv[])
QFont font("Open Sans");
app.setFont(font);
+ QString lang = QLocale::system().name();
+
+ QTranslator qtTranslator;
+ qtTranslator.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ app.installTranslator(&qtTranslator);
+
+ QTranslator appTranslator;
+ appTranslator.load("nheko_" + lang, ":/translations");
+ app.installTranslator(&appTranslator);
+
MainWindow w;
// Move the MainWindow to the center