From 31e5a0fe6d75e124bc772faafcef2618e16c3dbf Mon Sep 17 00:00:00 2001 From: Stiepen22 Date: Sun, 8 Sep 2013 18:13:09 +0200 Subject: [PATCH] Changed all strings displayed to end user to use qts localization system --- gui/EditNotesDialog.cpp | 2 +- gui/IconPickerDialog.cpp | 9 ++++++--- gui/LegacyModEditDialog.cpp | 12 ++++++++---- gui/OneSixModEditDialog.cpp | 4 ++-- gui/consolewindow.cpp | 3 ++- gui/logindialog.cpp | 8 ++++---- gui/lwjglselectdialog.cpp | 2 +- gui/mainwindow.cpp | 4 ++-- gui/settingsdialog.cpp | 12 ++++++------ logic/MinecraftProcess.cpp | 9 ++++++--- logic/tasks/LoginTask.cpp | 18 +++++++++--------- 11 files changed, 47 insertions(+), 36 deletions(-) diff --git a/gui/EditNotesDialog.cpp b/gui/EditNotesDialog.cpp index 6cc389f6..5b90ef53 100644 --- a/gui/EditNotesDialog.cpp +++ b/gui/EditNotesDialog.cpp @@ -12,7 +12,7 @@ EditNotesDialog::EditNotesDialog( QString notes, QString name, QWidget* parent ) { ui->setupUi(this); ui->noteEditor->setText(notes); - setWindowTitle("Edit notes of " + m_instance_name); + setWindowTitle(tr("Edit notes of %1").arg(m_instance_name)); //connect(ui->closeButton, SIGNAL(clicked()), SLOT(close())); } diff --git a/gui/IconPickerDialog.cpp b/gui/IconPickerDialog.cpp index 2dd80292..f3947d21 100644 --- a/gui/IconPickerDialog.cpp +++ b/gui/IconPickerDialog.cpp @@ -41,8 +41,8 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) : contentsWidget->setModel(MMC->icons()); - auto buttonAdd = ui->buttonBox->addButton("Add Icon",QDialogButtonBox::ResetRole); - auto buttonRemove = ui->buttonBox->addButton("Remove Icon",QDialogButtonBox::ResetRole); + auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole); + auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole); connect(buttonAdd,SIGNAL(clicked(bool)),SLOT(addNewIcon())); @@ -87,7 +87,10 @@ bool IconPickerDialog::eventFilter ( QObject* obj, QEvent* evt) void IconPickerDialog::addNewIcon() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Icons", QString(), "Icons (*.png *.jpg *.jpeg)"); + //: The title of the select icons open file dialog + QString selectIcons = tr("Select Icons"); + //: The type of icon files + QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), tr("Icons") + "(*.png *.jpg *.jpeg)"); MMC->icons()->installIcons(fileNames); } diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 616fc050..c336f837 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -183,7 +183,8 @@ bool LegacyModEditDialog::eventFilter ( QObject* obj, QEvent* ev ) void LegacyModEditDialog::on_addCoreBtn_clicked() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Core Mods"); + //: Title of core mod selection dialog + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Core Mods")); for(auto filename:fileNames) { m_coremods->stopWatching(); @@ -197,7 +198,8 @@ void LegacyModEditDialog::on_addForgeBtn_clicked() } void LegacyModEditDialog::on_addJarBtn_clicked() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Jar Mods"); + //: Title of jar mod selection dialog + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Jar Mods")); for(auto filename:fileNames) { m_jarmods->stopWatching(); @@ -207,7 +209,8 @@ void LegacyModEditDialog::on_addJarBtn_clicked() } void LegacyModEditDialog::on_addModBtn_clicked() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Loader Mods"); + //: Title of regular mod selection dialog + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Loader Mods")); for(auto filename:fileNames) { m_mods->stopWatching(); @@ -217,7 +220,8 @@ void LegacyModEditDialog::on_addModBtn_clicked() } void LegacyModEditDialog::on_addTexPackBtn_clicked() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Texture Packs"); + //: Title of texture pack selection dialog + QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Select Texture Packs")); for(auto filename:fileNames) { m_texturepacks->stopWatching(); diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index 8e738fa1..15ff09a5 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -112,7 +112,7 @@ void OneSixModEditDialog::on_buttonBox_rejected() void OneSixModEditDialog::on_addModBtn_clicked() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Loader Mods"); + QStringList fileNames = QFileDialog::getOpenFileNames(this, QApplication::translate("LegacyModEditDialog", "Select Loader Mods"); for(auto filename:fileNames) { m_mods->stopWatching(); @@ -139,7 +139,7 @@ void OneSixModEditDialog::on_viewModBtn_clicked() void OneSixModEditDialog::on_addResPackBtn_clicked() { - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Resource Packs"); + QStringList fileNames = QFileDialog::getOpenFileNames(this, QApplication::translate("LegacyModEditDialog", "Select Resource Packs")); for(auto filename:fileNames) { m_resourcepacks->stopWatching(); diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp index 8ea90d45..392eb50d 100644 --- a/gui/consolewindow.cpp +++ b/gui/consolewindow.cpp @@ -89,7 +89,8 @@ void ConsoleWindow::on_btnKillMinecraft_clicked() { ui->btnKillMinecraft->setEnabled(false); QMessageBox r_u_sure; - r_u_sure.setText("Kill Minecraft?"); + //: Main question of the kill confirmation dialog + r_u_sure.setText(tr("Kill Minecraft?")); r_u_sure.setInformativeText("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason"); r_u_sure.setStandardButtons(QMessageBox::Yes | QMessageBox::No); r_u_sure.setDefaultButton(QMessageBox::Yes); diff --git a/gui/logindialog.cpp b/gui/logindialog.cpp index a4dad1c1..37e30c85 100644 --- a/gui/logindialog.cpp +++ b/gui/logindialog.cpp @@ -24,8 +24,8 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) : { ui->setupUi(this); - //TODO: make translateable - offlineButton = new QPushButton("Offline Once"); + //: Use offline mode one time + offlineButton = new QPushButton(tr("Offline Once")); ui->loginButtonBox->addButton(offlineButton, QDialogButtonBox::ActionRole); @@ -33,8 +33,8 @@ LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) : isOnline_ = true; onlineForced = false; - //FIXME: translateable? - ui->usernameTextBox->lineEdit()->setPlaceholderText(QApplication::translate("LoginDialog", "Name", 0)); + //: The username during login (placeholder) + ui->usernameTextBox->lineEdit()->setPlaceholderText(tr("Name")); connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, SLOT(userTextChanged(QString))); connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser())); diff --git a/gui/lwjglselectdialog.cpp b/gui/lwjglselectdialog.cpp index 9de92754..c3215b7b 100644 --- a/gui/lwjglselectdialog.cpp +++ b/gui/lwjglselectdialog.cpp @@ -54,7 +54,7 @@ void LWJGLSelectDialog::loadingStateUpdated(bool loading) setEnabled(!loading); if (loading) { - ui->labelStatus->setText("Loading LWJGL version list..."); + ui->labelStatus->setText(tr("Loading LWJGL version list...")); ui->labelStatus->setStyleSheet("QLabel { color: black; }"); } ui->labelStatus->setVisible(loading); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 7ddc66a9..747df047 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -587,7 +587,7 @@ void MainWindow::on_actionMakeDesktopShortcut_triggered() Util::createShortCut ( Util::getDesktopDir(), QApplication::instance()->applicationFilePath(), QStringList() << "-dl" << QDir::currentPath() << "test", name, "application-x-octet-stream" ); - QMessageBox::warning ( this, "Not useful", "A Dummy Shortcut was created. it will not do anything productive" ); + QMessageBox::warning ( this, tr("Not useful"), tr("A Dummy Shortcut was created. it will not do anything productive") ); } // BrowserDialog @@ -658,7 +658,7 @@ void MainWindow::selectionBad() QString iconKey = "infinity"; statusBar()->clearMessage(); ui->instanceToolBar->setEnabled(false); - renameButton->setText("Rename Instance"); + renameButton->setText(tr("Rename Instance")); auto ico = MMC->icons()->getIcon(iconKey); ui->actionChangeInstIcon->setIcon(ico); } diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index a1fbb8e7..a5283b36 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -49,7 +49,7 @@ void SettingsDialog::updateCheckboxStuff() void SettingsDialog::on_instDirBrowseBtn_clicked() { - QString dir = QFileDialog::getExistingDirectory(this, "Instance Directory", + QString dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"), ui->instDirTextBox->text()); if (!dir.isEmpty()) ui->instDirTextBox->setText(dir); @@ -57,7 +57,7 @@ void SettingsDialog::on_instDirBrowseBtn_clicked() void SettingsDialog::on_modsDirBrowseBtn_clicked() { - QString dir = QFileDialog::getExistingDirectory(this, "Mods Directory", + QString dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"), ui->modsDirTextBox->text()); if (!dir.isEmpty()) ui->modsDirTextBox->setText(dir); @@ -65,7 +65,7 @@ void SettingsDialog::on_modsDirBrowseBtn_clicked() void SettingsDialog::on_lwjglDirBrowseBtn_clicked() { - QString dir = QFileDialog::getExistingDirectory(this, "LWJGL Directory", + QString dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"), ui->lwjglDirTextBox->text()); if (!dir.isEmpty()) ui->lwjglDirTextBox->setText(dir); @@ -99,9 +99,9 @@ void SettingsDialog::applySettings(SettingsObject *s) } else if (!s->get("UseDevBuilds").toBool()) { - int response = QMessageBox::question(this, "Development builds", - "Development builds contain experimental features " - "and may be unstable. Are you sure you want to enable them?"); + int response = QMessageBox::question(this, tr("Development builds"), + tr("Development builds contain experimental features " + "and may be unstable. Are you sure you want to enable them?")); if (response == QMessageBox::Yes) { s->set("UseDevBuilds", true); diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index c33d34a8..299f00be 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -120,9 +120,11 @@ void MinecraftProcess::finish(int code, ExitStatus status) // TODO: Localization if (!killed) - emit log("Minecraft exited."); + //: Message displayed on instance exit + emit log(tr("Minecraft exited with exitcode %1.").arg(status)); else - emit log("Minecraft was killed by user.", MessageLevel::Error); + //: Message displayed after the instance exits due to kill request + emit log(tr("Minecraft was killed by user."), MessageLevel::Error); m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code)); @@ -168,7 +170,8 @@ void MinecraftProcess::launch() start(JavaPath, m_args); if (!waitForStarted()) { - emit log("Could not launch minecraft!"); + //: Error message displayed if instace can't start + emit log(tr("Could not launch minecraft!")); return; //TODO: error handling } diff --git a/logic/tasks/LoginTask.cpp b/logic/tasks/LoginTask.cpp index ad9de7f5..859827bc 100644 --- a/logic/tasks/LoginTask.cpp +++ b/logic/tasks/LoginTask.cpp @@ -28,7 +28,7 @@ LoginTask::LoginTask( const UserInfo& uInfo, QObject* parent ) : Task(parent), u void LoginTask::executeTask() { - setStatus("Logging in..."); + setStatus(tr("Logging in...")); auto worker = MMC->qnam(); connect(worker, SIGNAL(finished(QNetworkReply*)), this, SLOT(processNetReply(QNetworkReply*))); @@ -76,36 +76,36 @@ void LoginTask::processNetReply(QNetworkReply *reply) } else { - emitFailed("Failed to parse Minecraft version string."); + emitFailed(tr("Failed to parse Minecraft version string.")); } } else { if (responseStr.toLower() == "bad login") - emitFailed("Invalid username or password."); + emitFailed(tr("Invalid username or password.")); else if (responseStr.toLower() == "old version") - emitFailed("Launcher outdated, please update."); + emitFailed(tr("Launcher outdated, please update.")); else - emitFailed("Login failed: " + responseStr); + emitFailed(tr("Login failed: %1").arg(responseStr)); } } else if (responseCode == 503) { - emitFailed("The login servers are currently unavailable. Check http://help.mojang.com/ for more info."); + emitFailed(tr("The login servers are currently unavailable. Check http://help.mojang.com/ for more info.")); } else { - emitFailed(QString("Login failed: Unknown HTTP error %1 occurred.").arg(QString::number(responseCode))); + emitFailed(tr("Login failed: Unknown HTTP error %1 occurred.").arg(QString::number(responseCode))); } break; } case QNetworkReply::OperationCanceledError: - emitFailed("Login canceled."); + emitFailed(tr("Login canceled.")); break; default: - emitFailed("Login failed: " + reply->errorString()); + emitFailed(tr("Login failed: %1").arg(reply->errorString())); break; } }