From 767a651735854d3872f2ee81d6e77770b57ac146 Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sat, 25 Apr 2020 18:15:00 +0800 Subject: [PATCH] Add support for multilanguage --- lang/en_US.ts | 209 +++++++++++------- lang/zh_CN.ts | 359 ++++++++++++++++++------------- main.cpp | 34 +++ module/mifare.cpp | 8 +- ui/mainwindow.cpp | 11 +- ui/mainwindow.h | 1 + ui/mainwindow.ui | 6 +- ui/mf_attack_hardnesteddialog.ui | 6 +- 8 files changed, 404 insertions(+), 230 deletions(-) diff --git a/lang/en_US.ts b/lang/en_US.ts index b949903..729092e 100644 --- a/lang/en_US.ts +++ b/lang/en_US.ts @@ -1,16 +1,16 @@ - + MF_Attack_hardnestedDialog - Dialog + Hardnested Attack - Known Key: + Known Block: @@ -38,7 +38,35 @@ - Target Key: + Target Block: + + + + + MF_UID_parameterDialog + + + Dialog + + + + + UID: + + + + + ATQA: + + + + + SAK: + + + + + The parameter will not change if you leave it empty. @@ -95,288 +123,323 @@ - - 1K + + MINI + 1K + + + + 2K - + 4K - + File - - + + Load - - + + Save - - + + Data - + Key - + Attack - + Card Info - + Check Default - + Nested - + Hardnested - + Read/Write - + Block: - + Key: - + FFFFFFFFFFFF - + Key Type: - + A - + B - + Normal(Require Password) - - + + Read Block - - + + Write Block - - - + + + Read All - - + + Write All - + Dump - + Restore - + Chinese Magic Card(Without Password) - + Lock UFUID Card - + About UID Card - - Write UID + + Set Parameter - + Wipe - - + + Simulate - + Load from data above - + Clear - - + + Sniff - + List Sniff Data - + RawCommand - - + + History: - + ClearHistory - + Send - + ClearOutput - + + Info - + Plz choose a port first - + Connected - - - + + + Not Connected - + + When Changeing card type, the data and keys in this app will be cleard. +Continue? + + + + Idle - - + + Sec - + Blk - + KeyA - + KeyB - + HW Version: - + PM3: - + State: + + Mifare + + + + Success! + + + + + + + + Info + + + + + + Failed! + + + diff --git a/lang/zh_CN.ts b/lang/zh_CN.ts index b949903..1dddb58 100644 --- a/lang/zh_CN.ts +++ b/lang/zh_CN.ts @@ -1,45 +1,77 @@ - + MF_Attack_hardnestedDialog - Dialog - + Hardnested Attack + Hardnested攻击 - Known Key: - + 已知Key: + + + + Known Block: + 已知块: Block: - + 块: A - + B - + FFFFFFFFFFFF - + - Target Key: - + Target Block: + 目标块: + + + + MF_UID_parameterDialog + + + Dialog + 对话框 + + + + UID: + + + + + ATQA: + + + + + SAK: + + + + + The parameter will not change if you leave it empty. + 如果留空,则对应参数将保持不变 @@ -47,336 +79,375 @@ Proxmark3GUI - + Path: - + 路径: E:\Documents\source\qt\pm3\win64\proxmark3 - + Refresh - + 刷新端口 Connect - + 连接 Disconnect - + 断开 Mifare - + Mifare卡 >> - + << - + Card Type - + 卡类型 - - 1K - + + MINI + + 1K + + + + 2K - + - + 4K - + - + File - + 文件 - - + + Load - + 加载 - - + + Save - + 保存 - - + + Data - + - + Key - + - + Attack - + 破解 - + Card Info - + 读卡片信息 - + Check Default - + 验证默认密码 - + Nested - + Nested攻击 - + Hardnested - + Hardested攻击 - + Read/Write - + 读/写 - + Block: - + - + Key: - + - + FFFFFFFFFFFF - + - + Key Type: - + Key类型: - + A - + - + B - + - + Normal(Require Password) - + 普通卡(需要密码) - - + + Read Block - + 读单个块 - - + + Write Block - + 写单个块 - - - + + + Read All - + 读所有块 - - + + Write All - + 写所有块 - + Dump - + Dump命令 - + Restore - + Restore命令 - + Chinese Magic Card(Without Password) - + UID卡(不需要密码) - + Lock UFUID Card - + 锁定UFUID卡 - + About UID Card - + 关于UID卡 - - Write UID - + + Set Parameter + 设置卡参数 - + Wipe - + 擦除 - - + + Simulate - + 模拟 - + Load from data above - + 从上方数据导入 - + Clear - + 清空 - - + + Sniff - + 嗅探 - + List Sniff Data - + 列出嗅探数据 - + RawCommand - + 原始命令 - - + + History: - + 命令历史: - + ClearHistory - + 清空历史 - + Send - + 发送 - + ClearOutput - + 清空输出 - + + Info - + 信息 - + Plz choose a port first - + 请先选择端口 - + Connected - + 已连接 - - - + + + Not Connected - + 未连接 - + + When Changeing card type, the data and keys in this app will be cleard. +Continue? + 更改卡容量后,窗口中的data和key会被清空\n要继续吗? + + + Idle - + 空闲 - - + + Sec - + - + Blk - + - + KeyA - + - + KeyB - + - + HW Version: - + 固件版本: - + PM3: - + 连接状态: - + State: - + 运行状态: + + + + Mifare + + info + 信息: + + + + + Success! + 成功! + + + + + + + Info + 信息 + + + + + Failed! + 失败! diff --git a/main.cpp b/main.cpp index 9928c62..cc52578 100644 --- a/main.cpp +++ b/main.cpp @@ -1,11 +1,45 @@ #include "ui/mainwindow.h" #include +#include +#include +#include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; + QSettings* settings = new QSettings("GUIsettings.ini", QSettings::IniFormat); + QVariant lang = settings->value("lang", "null"); + if(lang == "null") + { + lang = "lang/en_US.qm"; + QStringList langList; + langList.append("English"); + langList.append("简体中文"); + QString seletedText = QInputDialog::getItem(&w, "", "Choose a language:", langList, 0, false); + if(seletedText == "English") + { + lang = "lang/en_US.qm"; + } + else if(seletedText == "简体中文") + { + lang = "lang/zh_CN.qm"; + } + } + QTranslator* translator = new QTranslator(&w); + if(translator->load(lang.toString())) + { + a.installTranslator(translator); + settings->setValue("lang", lang); + } + else + { + QMessageBox::information(&w, "Error", "Can't load " + lang.toString() + " as translation file."); + } + delete settings; + w.initUI(); w.show(); return a.exec(); } diff --git a/module/mifare.cpp b/module/mifare.cpp index 5d127a1..db70d5a 100644 --- a/module/mifare.cpp +++ b/module/mifare.cpp @@ -266,11 +266,11 @@ void Mifare::write() + ui->MF_RW_dataEdit->text().replace(" ", ""), waitTime); if(result.indexOf("isOk:01") != -1) { - QMessageBox::information(parent, tr("info"), tr("Success!")); + QMessageBox::information(parent, tr("Info"), tr("Success!")); } else { - QMessageBox::information(parent, tr("info"), tr("Failed!")); + QMessageBox::information(parent, tr("Info"), tr("Failed!")); } } @@ -363,11 +363,11 @@ void Mifare::writeC() + ui->MF_RW_dataEdit->text().replace(" ", ""), waitTime); if(result.indexOf("No chinese") == -1) { - QMessageBox::information(parent, tr("info"), tr("Success!")); + QMessageBox::information(parent, tr("Info"), tr("Success!")); } else { - QMessageBox::information(parent, tr("info"), tr("Failed!")); + QMessageBox::information(parent, tr("Info"), tr("Failed!")); } } diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 54c7190..0a0cb7a 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -18,8 +18,6 @@ MainWindow::MainWindow(QWidget *parent) mifare = new Mifare(ui, util, this); - uiInit(); - signalInit(); } MainWindow::~MainWindow() @@ -32,6 +30,13 @@ MainWindow::~MainWindow() delete pm3Thread; } +void MainWindow::initUI() +{ + ui->retranslateUi(this); + uiInit(); + signalInit(); +} + // ******************** basic functions ******************** void MainWindow::on_PM3_refreshPortButton_clicked() @@ -162,7 +167,7 @@ void MainWindow::MF_onTypeChanged(int id, bool st) qDebug() << id << typeBtnGroup->checkedId(); if(!st) { - int result = QMessageBox::question(this, tr("info"), tr("When Changeing card type, the data and keys in this app will be cleard.\nContinue?"), QMessageBox::Yes | QMessageBox::No); + int result = QMessageBox::question(this, tr("Info"), tr("When Changeing card type, the data and keys in this app will be cleard.\nContinue?"), QMessageBox::Yes | QMessageBox::No); if(result == QMessageBox::Yes) { qDebug() << "Yes"; diff --git a/ui/mainwindow.h b/ui/mainwindow.h index 45a39f7..0aaf37d 100644 --- a/ui/mainwindow.h +++ b/ui/mainwindow.h @@ -30,6 +30,7 @@ public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); + void initUI(); public slots: void refreshOutput(const QString &output); void refreshCMD(const QString &cmd); diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 399b511..08f8714 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -42,7 +42,7 @@ - E:\Documents\source\qt\pm3\win64\proxmark3 + E:\Documents\source\qt\pm3\win64\proxmark3 @@ -394,7 +394,7 @@ - 40 + 0 0 @@ -485,7 +485,7 @@ - FFFFFFFFFFFF + FFFFFFFFFFFF diff --git a/ui/mf_attack_hardnesteddialog.ui b/ui/mf_attack_hardnesteddialog.ui index f6144d5..d6af01d 100644 --- a/ui/mf_attack_hardnesteddialog.ui +++ b/ui/mf_attack_hardnesteddialog.ui @@ -17,7 +17,7 @@ - Known Key: + Known Block: @@ -83,7 +83,7 @@ - FFFFFFFFFFFF + FFFFFFFFFFFF @@ -92,7 +92,7 @@ - Target Key: + Target Block: