From 15bdbef4a09d1145d08e30fa88d9dc2f29662ebb Mon Sep 17 00:00:00 2001 From: Alexandr Filatov Date: Sat, 9 Sep 2017 12:36:15 +0300 Subject: [PATCH] Add tr() to visible strings; fix #119 (#209) * Add tr() to visible strings; close #119 --- src/createnewdialog.cpp | 28 ++++++++++++++-------------- src/dialogs/aboutdialog.cpp | 4 ++-- src/main.cpp | 6 +++--- src/mainwindow.cpp | 16 ++++++++-------- src/newfiledialog.cpp | 4 ++-- src/optionsdialog.cpp | 16 ++++++++-------- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/createnewdialog.cpp b/src/createnewdialog.cpp index 4d590214..4c745446 100644 --- a/src/createnewdialog.cpp +++ b/src/createnewdialog.cpp @@ -64,7 +64,7 @@ void createNewDialog::on_exampleButton_clicked() { str = "48656c6c6f20576f726c6400"; } - else fprintf(stderr, "Unknown combo value selected"); + else fprintf(stderr, tr("Unknown combo value selected").toLocal8Bit().constData()); if (str.length() > 0) ui->plainTextEdit->setPlainText(str); // } @@ -95,12 +95,12 @@ void createNewDialog::on_buttonCreate_clicked() } else { - __alert("Failed to create file"); + __alert(tr("Failed to create file")); } } else { - __alert("Invalid assembler code"); + __alert(tr("Invalid assembler code")); } r_asm_code_free(code); } @@ -119,12 +119,12 @@ void createNewDialog::on_buttonCreate_clicked() } else { - __alert("failed to open file"); + __alert(tr("Failed to open file")); } } else { - __alert("Invalid file size"); + __alert(tr("Invalid file size")); } } else if (type == "C Code") @@ -151,12 +151,12 @@ void createNewDialog::on_buttonCreate_clicked() } else { - __alert("failed to open file"); + __alert(tr("Failed to open file")); } } else { - __alert("Invalid file size"); + __alert(tr("Invalid file size")); } } else if (type == "Text") @@ -174,12 +174,12 @@ void createNewDialog::on_buttonCreate_clicked() } else { - __alert("failed to open file"); + __alert(tr("Failed to open file")); } } else { - __alert("Empty string?"); + __alert(tr("Empty string?")); } } else if (type == "Hexpairs") @@ -199,18 +199,18 @@ void createNewDialog::on_buttonCreate_clicked() } else { - __alert("failed to open file"); + __alert(tr("Failed to open file")); } } else { - __alert("Invalid hexpair string"); + __alert(tr("Invalid hexpair string")); } free(buf); } else { - __alert("Unknown combo value selected"); + __alert(tr("Unknown combo value selected")); return; } @@ -230,12 +230,12 @@ void createNewDialog::on_buttonCreate_clicked() w->core->seek(0); w->updateFrames(); w->setFilename("-"); - w->addOutput("Finished, check its contents"); + w->addOutput(tr("Finished, check its contents")); w->showMaximized(); } else { - __alert("No file created."); + __alert(tr("No file created.")); } } diff --git a/src/dialogs/aboutdialog.cpp b/src/dialogs/aboutdialog.cpp index f0650055..339dc6cb 100644 --- a/src/dialogs/aboutdialog.cpp +++ b/src/dialogs/aboutdialog.cpp @@ -8,13 +8,13 @@ AboutDialog::AboutDialog(QWidget *parent) : { ui->setupUi(this); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); - ui->label->setText("

Iaito

" + ui->label->setText(tr("

Iaito

" "Version 1.0 alpha
" "Using r2-" R2_GITTAP "

License

" "This Software is released under the GNU General Public License v3.0" "

Authors

" - "Hugo Teso <hugo.teso@gmail.org>\nSoon to be thousands more!"); + "Hugo Teso <hugo.teso@gmail.org>\nSoon to be thousands more!")); } AboutDialog::~AboutDialog() diff --git a/src/main.cpp b/src/main.cpp index 5e295bf8..4d7e473b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) QCommandLineParser cmd_parser; - cmd_parser.setApplicationDescription("A Qt and C++ GUI for radare2 reverse engineering framework"); + cmd_parser.setApplicationDescription(QObject::tr("A Qt and C++ GUI for radare2 reverse engineering framework")); cmd_parser.addHelpOption(); cmd_parser.addVersionOption(); cmd_parser.addPositionalArgument("filename", QObject::tr("Filename to open.")); @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) msg.setIcon(QMessageBox::Critical); msg.setWindowIcon(QIcon(":/img/logo-small.png")); msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msg.setWindowTitle("Version mismatch!"); - msg.setText(QString("The version used to compile iaito (%1) does not match the binary version of radare2 (%2). This could result in unexpected behaviour. Are you sure you want to continue?").arg(localVersion, r2version)); + msg.setWindowTitle(QObject::tr("Version mismatch!")); + msg.setText(QString(QObject::tr("The version used to compile iaito (%1) does not match the binary version of radare2 (%2). This could result in unexpected behaviour. Are you sure you want to continue?")).arg(localVersion, r2version)); if (msg.exec() == QMessageBox::No) return 1; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index df6b66d1..1e8a7dfd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -345,7 +345,7 @@ void MainWindow::finalizeOpen() core->setSettings(); - addOutput(" > Populating UI"); + addOutput(tr(" > Populating UI")); // FIXME: initialization order frakup. the next line is needed so that the // comments widget displays the function names. core->cmd("fs sections"); @@ -364,9 +364,9 @@ void MainWindow::finalizeOpen() } else { - addOutput(" > Adding binary information to notepad"); + addOutput(tr(" > Adding binary information to notepad")); - notepadDock->setText("# Binary information\n\n" + core->cmd("i") + + notepadDock->setText(tr("# Binary information\n\n") + core->cmd("i") + "\n" + core->cmd("ie") + "\n" + core->cmd("iM") + "\n"); } @@ -374,7 +374,7 @@ void MainWindow::finalizeOpen() this->core->binStart = this->core->cmd("?v $M"); this->core->binEnd = this->core->cmd("?v $M+$s"); - addOutput(" > Finished, happy reversing :)"); + addOutput(tr(" > Finished, happy reversing :)")); // Add fortune message addOutput("\n" + core->cmd("fo")); memoryDock->setWindowTitle("entry0"); @@ -449,7 +449,7 @@ void MainWindow::saveProject() QString notes = this->notepadDock->textToBase64(); //this->add_debug_output(notes); this->core->cmd("Pnj " + notes); - this->addOutput("Project saved: " + project_name); + this->addOutput(tr("Project saved: ") + project_name); } void MainWindow::start_web_server() @@ -501,7 +501,7 @@ void MainWindow::setFilename(const QString &fn) void MainWindow::closeEvent(QCloseEvent *event) { QMessageBox::StandardButton ret = QMessageBox::question(this, "Iaito", - "Do you really want to exit?\nSave your project before closing!", + tr("Do you really want to exit?\nSave your project before closing!"), (QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel)); //qDebug() << ret; if (ret == QMessageBox::Save) @@ -963,7 +963,7 @@ void MainWindow::on_actionRun_Script_triggered() dialog.setDirectory(QDir::home()); QString fileName; - fileName = dialog.getOpenFileName(this, "Select radare2 script"); + fileName = dialog.getOpenFileName(this, tr("Select radare2 script")); if (!fileName.length()) //cancel was pressed return; @@ -1047,7 +1047,7 @@ void MainWindow::on_actionReset_settings_triggered() { QMessageBox::StandardButton ret = (QMessageBox::StandardButton)QMessageBox::question(this, "Iaito", - "Do you really want to clear all settings?", + tr("Do you really want to clear all settings?"), QMessageBox::Ok | QMessageBox::Cancel); if (ret == QMessageBox::Ok) { diff --git a/src/newfiledialog.cpp b/src/newfiledialog.cpp index e999399d..7d3766ee 100644 --- a/src/newfiledialog.cpp +++ b/src/newfiledialog.cpp @@ -99,7 +99,7 @@ void NewFileDialog::on_loadFileButton_clicked() if (!checkfile.exists() || !checkfile.isFile()) { QMessageBox msgBox(this); - msgBox.setText("Select a new program or a previous one\nbefore continue"); + msgBox.setText(tr("Select a new program or a previous one\nbefore continue")); msgBox.exec(); } else @@ -132,7 +132,7 @@ void NewFileDialog::on_newFileButton_clicked() dialog.setDirectory(QDir::home()); QString fileName; - fileName = dialog.getOpenFileName(this, "Select file"); + fileName = dialog.getOpenFileName(this, tr("Select file")); if (!fileName.isEmpty()) { diff --git a/src/optionsdialog.cpp b/src/optionsdialog.cpp index 79544c9e..52d2cc69 100644 --- a/src/optionsdialog.cpp +++ b/src/optionsdialog.cpp @@ -70,7 +70,7 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) ui->progressBar->setVisible(1); ui->statusLabel->setVisible(1); - ui->statusLabel->setText("Starting analysis"); + ui->statusLabel->setText(tr("Starting analysis")); //ui->progressBar->setValue(5); int va = ui->vaCheckBox->isChecked(); @@ -126,14 +126,14 @@ void OptionsDialog::setupAndStartAnalysis(int level, QList advanced) } //ui->progressBar->setValue(20); - ui->statusLabel->setText("Loading binary"); + ui->statusLabel->setText(tr("Loading binary")); // options dialog should show the list of archs inside the given fatbin int binidx = 0; // index of subbin - main->addOutput(" > Loading file: " + main->getFilename()); + main->addOutput(tr(" > Loading file: ") + main->getFilename()); main->core->loadFile(main->getFilename(), loadaddr, mapaddr, rw, va, binidx, load_bininfo); //ui->progressBar->setValue(40); - ui->statusLabel->setText("Analysis in progress"); + ui->statusLabel->setText(tr("Analysis in progress")); // Threads stuff // connect signal/slot @@ -189,8 +189,8 @@ void OptionsDialog::on_okButton_clicked() void OptionsDialog::anal_finished() { - ui->statusLabel->setText("Loading interface"); - main->addOutput(" > Analysis finished"); + ui->statusLabel->setText(tr("Loading interface")); + main->addOutput(tr(" > Analysis finished")); QString initial_seek = ui->entry_initialSeek->text(); if (initial_seek.length() > 0) @@ -241,12 +241,12 @@ void OptionsDialog::on_analSlider_valueChanged(int value) if (value == 0) { ui->analCheckBox->setChecked(false); - ui->analCheckBox->setText("Analysis: Disabled"); + ui->analCheckBox->setText(tr("Analysis: Disabled")); } else { ui->analCheckBox->setChecked(true); - ui->analCheckBox->setText("Analysis: Enabled"); + ui->analCheckBox->setText(tr("Analysis: Enabled")); if (value==3) { ui->analoptionsFrame->setVisible(true);