From d3b665037d660b0e85429ae571e378bdbacd53a6 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Wed, 8 Jun 2022 13:59:09 +0800 Subject: [PATCH] feat: good translate --- .../inputconvert/inputconvertgame.cpp | 2 +- .../controller/inputconvert/keymap/keymap.cpp | 2 +- QtScrcpy/QtScrcpyCore/src/device/device.cpp | 10 +- QtScrcpy/res/i18n/CMakeLists.txt | 5 +- QtScrcpy/res/i18n/en_US.qm | Bin 4577 -> 4625 bytes QtScrcpy/res/i18n/en_US.ts | 146 +----------------- QtScrcpy/res/i18n/zh_CN.qm | Bin 3884 -> 3616 bytes QtScrcpy/res/i18n/zh_CN.ts | 130 +--------------- QtScrcpy/ui/dialog.ui | 2 +- ci/lrelease.sh | 3 + ci/lupdate.sh | 4 + 11 files changed, 28 insertions(+), 276 deletions(-) create mode 100644 ci/lrelease.sh create mode 100644 ci/lupdate.sh diff --git a/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/inputconvertgame.cpp b/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/inputconvertgame.cpp index e0871f8..88b584e 100644 --- a/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/inputconvertgame.cpp +++ b/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/inputconvertgame.cpp @@ -624,7 +624,7 @@ void InputConvertGame::stopMouseMoveTimer() bool InputConvertGame::switchGameMap() { m_gameMap = !m_gameMap; - qInfo() << tr("current keymap mode: %1").arg(m_gameMap ? tr("custom") : tr("normal")); + qInfo() << QString("current keymap mode: %1").arg(m_gameMap ? "custom" : "normal"); if (!m_keyMap.isValidMouseMoveMap()) { return m_gameMap; diff --git a/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/keymap/keymap.cpp b/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/keymap/keymap.cpp index 446096f..2e810fd 100644 --- a/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/keymap/keymap.cpp +++ b/QtScrcpy/QtScrcpyCore/src/device/controller/inputconvert/keymap/keymap.cpp @@ -290,7 +290,7 @@ void KeyMap::loadKeyMap(const QString &json) } // this must be called after m_keyMapNodes is stable makeReverseMap(); - qInfo() << tr("Script updated, current keymap mode:normal, Press ~ key to switch keymap mode"); + qInfo() << "Script updated, current keymap mode:normal, Press ~ key to switch keymap mode"; parseError: if (!errorString.isEmpty()) { diff --git a/QtScrcpy/QtScrcpyCore/src/device/device.cpp b/QtScrcpy/QtScrcpyCore/src/device/device.cpp index 7938606..c62cdd5 100644 --- a/QtScrcpy/QtScrcpyCore/src/device/device.cpp +++ b/QtScrcpy/QtScrcpyCore/src/device/device.cpp @@ -148,19 +148,19 @@ void Device::initSignals() connect(m_fileHandler, &FileHandler::fileHandlerResult, this, [this](FileHandler::FILE_HANDLER_RESULT processResult, bool isApk) { QString tipsType = ""; if (isApk) { - tipsType = tr("install apk"); + tipsType = "install apk"; } else { - tipsType = tr("file transfer"); + tipsType = "file transfer"; } QString tips; if (FileHandler::FAR_IS_RUNNING == processResult) { - tips = tr("wait current %1 to complete").arg(tipsType); + tips = QString("wait current %1 to complete").arg(tipsType); } if (FileHandler::FAR_SUCCESS_EXEC == processResult) { - tips = tr("%1 complete, save in %2").arg(tipsType).arg(m_params.pushFilePath); + tips = QString("%1 complete, save in %2").arg(tipsType).arg(m_params.pushFilePath); } if (FileHandler::FAR_ERROR_EXEC == processResult) { - tips = tr("%1 failed").arg(tipsType); + tips = QString("%1 failed").arg(tipsType); } qInfo() << tips; }); diff --git a/QtScrcpy/res/i18n/CMakeLists.txt b/QtScrcpy/res/i18n/CMakeLists.txt index 6fd32cd..bf3dad8 100644 --- a/QtScrcpy/res/i18n/CMakeLists.txt +++ b/QtScrcpy/res/i18n/CMakeLists.txt @@ -38,7 +38,10 @@ qt5_create_translation在cmake clean的时候会删除翻译好的ts文件,导 上面3个方案都有一个共同问题:就是翻译文件处理都是和编译绑定在一起的,每次编译都会检测执行,实际的翻译工作是所有 编程工作都完成以后,统一执行一次lupdate、翻译、lrelease就可以了,不应该和编译绑定在一起 -所以写两个shell脚本lupdate.sh和lrelease.sh来处理比较合适 +所以写两个shell脚本lupdate.sh和lrelease.sh来处理比较合适,其实非常简单: +1. 更新ts:lupdate -no-obsolete ./QtScrcpy -ts ./QtScrcpy/res/i18n/en_US.ts ./QtScrcpy/res/i18n/zh_CN.ts +2. 手动翻译ts +3. 发布:lrelease ./QtScrcpy/res/i18n/en_US.ts ./QtScrcpy/res/i18n/zh_CN.ts 参考文档 1. qt知道qt5_create_translation的bug,但是不肯解决,只确定了qt6没问题 https://bugreports.qt.io/browse/QTBUG-96549 diff --git a/QtScrcpy/res/i18n/en_US.qm b/QtScrcpy/res/i18n/en_US.qm index 65c81258e88d636dfcefe1dd3e5a5ec05f8bda0c..e64c864c3008344e95d27d17d2f1dc3a09fba0d8 100644 GIT binary patch delta 971 zcmaE;JW*wWY(3)#2G(sc3=BLW3~b*_85nr?GqBr)GBEJIU|{cIVPIgr&%i!Eoq>VF zfI()n1p@=$3kEaMMGOoahZ!=;Eg2Y?zA$8IH!(0UFJdUqJ;cDk=g-ii>CC{uDbe2e`TMP_L#Vn0U8yOfFl3Cf)v=|szxLL(bUo$YU z*0Ac$S<1k`xRW(({Zs}9hDB@@kGmKcm~+@B@VPKBa2c{YNDDJCu-#>M*M7>tz}Uv# zv!{=Nfv=i`F= z`xh>G`zH(xj9y$0$M!KWuxD{qHFGgAu)1;Q*G*+$;AG-Hpk05Hfq~~I_lf;(3=HhM zd7R=x7#P@9dFsrsFfj0~;(5L1C<6ma0MC0XF9rq%2HuJ3vltjye(?T!@PvVZiIGp* zvW0s}a)v~PB8F531*mv3 zLq0<;Ljgk$Ln=cFLn=cKLnVU(Lq0JEoYSn8Atz6r5}f3=9<^ z8JYFP3dQ+pCFO}lsS26J3d#Ao1v#lDsX3Jj`30$Y3dQ-QMaiiOiFqjsX+^22dJ3V% zsS24T3W+5OmHDMb3i;)E3PqX4*?J0*`K1cUiFpbs`Q>>z`H3k|RV5jz3TgQ{Ir-(8 zdFcv?DJey%#l=?a3=9nHf&NKZsZ7Zwo2&VB7>%SD(iw`tUM>K8I-enrp#&_F19vcQ WdQpC9fkJYAUP)1Y&gQB7K1=|HE$puV delta 940 zcmbQJ@=$q#Y&{bP1M9XJ1_qu02DWde3=F*G4D2?c3=F&r7}$GQ7#P^&8QABiGca&& zV365t!N9<`fWb_35d#C4GebtXB?ALX2}72469WUQ5<_|JAqECMc7`5JX9fo51B{lB z&M`3XY+~Eg$V_@Jt$^P9l zj)8&KlEcPPnSp_gfg{f7Gy?;}4UT`zG7JptI-CwhsSFI<_MC|qSQr?%xHwBAzA!Mb z%;VzL+seSeUCJf5N`irbvxH0D{s{vE(@7Ft8ot&aa!wz`)hS zeL(vr0|U=j?i2gn7#KLMd7R=x7#KK~^3<7MVPN1(;(5L1C<6oQ1)ld-UJMM34ZIW6 zXE89aRq+0L@PvVZxsgxWvW0Q^pCsm=OC^4@%Ewu>U1TnCqiy2B75*czB za_Sir7!nx@7_#Boxij;MOA>Q(6cP)v(KVYfl!KjH0uGr{h9ZU{hE#?;1`r<-UL_3q zU^$dfgPSc~o|svpkX%|+l$uwfplYa4B9;#iE@aC#i!fc`+ML6u&bawHzZDYzK9ABw diff --git a/QtScrcpy/res/i18n/en_US.ts b/QtScrcpy/res/i18n/en_US.ts index 213c7b0..986bd01 100644 --- a/QtScrcpy/res/i18n/en_US.ts +++ b/QtScrcpy/res/i18n/en_US.ts @@ -1,46 +1,6 @@ - - Device - - wait current file transfer to complete - wait current file transfer to complete - - - file transfer complete - file transfer complete - - - file transfer failed - file transfer failed - - - install apk - install apk - - - file transfer - file transfer - - - wait current %1 to complete - wait current %1 to complete - - - %1 complete, save in %2 - %1 complete, save in %2 - - - %1 complete - save in %2 - %1 complete\n save in %2 - - - %1 failed - %1 failed - - Dialog @@ -149,10 +109,6 @@ reverse connection reverse connection - - auto enable - auto enable - background record background record @@ -197,10 +153,6 @@ device serial: device serial: - - Config - Config - bit rate: bit rate: @@ -231,31 +183,6 @@ no lock no lock - - warning - Warning - Warning - - - Quit or set tray? - Quit or set tray? - Quit or set tray? - - - Quit - Quit - Quit - - - Set tray - Set tray - Set tray - - - Cancel - Cancel - Cancel - Notice Notice @@ -266,52 +193,12 @@ Hidden here! Hidden here! - - 2 - - - - - InputConvertGame - - current keymap mode: %1 - - - - custom - - - - normal - - - - - KeyMap - - Script updated, current keymap mode:normal, Press ~ key to switch keymap mode - - QObject - - This software is completely open source and free, you can download it at the following address: - This software is completely open source and free, you can download it at the following address: - - - This software is completely open source and free. -Strictly used for illegal purposes, or at your own risk. -You can download it at the following address: - This software is completely open source and free.\nStrictly used for illegal purposes, or at your own risk.\nYou can download it at the following address: - - - This software is completely open source and free. Strictly used for illegal purposes, or at your own risk. You can download it at the following address: - This software is completely open source and free. Strictly used for illegal purposes, or at your own risk. You can download it at the following address: - This software is completely open source and free. Use it at your own risk. You can download it at the following address: - + This software is completely open source and free. Use it at your own risk. You can download it at the following address: @@ -328,14 +215,6 @@ You can download it at the following address: expand notify expand notify - - turn off - turn off - - - turn on - turn on - touch switch touch switch @@ -380,31 +259,16 @@ You can download it at the following address: open screen open screen + + group control + group control + VideoForm - - wait current file transfer to complete - wait current file transfer to complete - - - file transfer complete - file transfer complete - - - file transfer failed - file transfer failed - file does not exist file does not exist - - videoForm - - qrc:/qml/pinwheel.qml - qrc:/qml/pinwheel.qml - - diff --git a/QtScrcpy/res/i18n/zh_CN.qm b/QtScrcpy/res/i18n/zh_CN.qm index 0e05298ed075ba96acd1d382fa72728e9ce3c1ba..b98cc9c445cc04b0104b4add26500fb50e56c859 100644 GIT binary patch delta 557 zcmZ1@w?JlsY(3)#2G(sc3=Et$3~b*_85p>H8Q5(?85p=q7}$GQ7#LV)GqBH3XJB9p zVUXEu!N9=n#9$`6h=GCaDnmxOB?ALf5JQ%B69WU&Er#;kLktXDCmDJ)of#MyPcT|O zI>*4kIf2n$&Vhk}c?)B}(di5f3}+d4wM=4QU^isEaYl-vo`LB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5!- zLRZff-Pv)JA(5egAseoPJ2S7iBrzvPA+aDEUA;iHXMAgXaF8#9syW1WaBb4%iJ2t| g$)!a_sd*&|s)hEzX#fBK diff --git a/QtScrcpy/res/i18n/zh_CN.ts b/QtScrcpy/res/i18n/zh_CN.ts index 8babd7b..a356f7e 100644 --- a/QtScrcpy/res/i18n/zh_CN.ts +++ b/QtScrcpy/res/i18n/zh_CN.ts @@ -1,46 +1,6 @@ - - Device - - wait current file transfer to complete - 等待当前文件传输完成 - - - file transfer complete - 文件传输完成 - - - file transfer failed - 文件传输失败 - - - install apk - 安装apk - - - file transfer - 文件传输 - - - wait current %1 to complete - 等待当前%1完成 - - - %1 complete, save in %2 - %1完成,保存在%2 - - - %1 complete - save in %2 - %1完成\n 保存在 %2 - - - %1 failed - %1 失败 - - Dialog @@ -149,10 +109,6 @@ reverse connection 反向连接 - - auto enable - 自动启用脚本 - background record 后台录制 @@ -197,10 +153,6 @@ device serial: 设备序列号: - - Config - 配置 - bit rate: 比特率: @@ -231,31 +183,6 @@ no lock 不锁定 - - warning - 警告 - 警告 - - - Quit or set tray? - 退出还是最小化到托盘? - 退出还是最小化到托盘? - - - Quit - 退出 - 退出 - - - Set tray - 最小化到系统托盘 - 最小化到系统托盘 - - - Cancel - 取消 - 取消 - Notice 提示 @@ -266,32 +193,6 @@ 安卓录屏程序隐藏在这! 安卓录屏程序隐藏在这! - - 2 - - - - - InputConvertGame - - current keymap mode: %1 - - - - custom - - - - normal - - - - - KeyMap - - Script updated, current keymap mode:normal, Press ~ key to switch keymap mode - - QObject @@ -314,14 +215,6 @@ expand notify 下拉通知 - - turn off - 锁屏 - - - turn on - 解锁 - touch switch 触摸显示开关 @@ -366,31 +259,16 @@ open screen 打开屏幕 + + group control + 群控 + VideoForm - - wait current file transfer to complete - 等待当前文件传输完成 - - - file transfer complete - 文件传输完成 - - - file transfer failed - 文件传输失败 - file does not exist 文件不存在 - - videoForm - - qrc:/qml/pinwheel.qml - qrc:/qml/pinwheel.qml - - diff --git a/QtScrcpy/ui/dialog.ui b/QtScrcpy/ui/dialog.ui index 1e5c829..97f4f0c 100644 --- a/QtScrcpy/ui/dialog.ui +++ b/QtScrcpy/ui/dialog.ui @@ -324,7 +324,7 @@ - 2 + 2 diff --git a/ci/lrelease.sh b/ci/lrelease.sh new file mode 100644 index 0000000..d3b2e4f --- /dev/null +++ b/ci/lrelease.sh @@ -0,0 +1,3 @@ +# https://doc.qt.io/qt-5/linguist-manager.html#lrelease +# lrelease -help +lrelease ./QtScrcpy/res/i18n/en_US.ts ./QtScrcpy/res/i18n/zh_CN.ts \ No newline at end of file diff --git a/ci/lupdate.sh b/ci/lupdate.sh new file mode 100644 index 0000000..92ef2f6 --- /dev/null +++ b/ci/lupdate.sh @@ -0,0 +1,4 @@ +# https://doc.qt.io/qt-5/linguist-manager.html#lupdate +# lupdate -help +# export PATH=/D/Qt/5.15.2/msvc2019/bin:$PATH +lupdate -no-obsolete ./QtScrcpy -ts ./QtScrcpy/res/i18n/en_US.ts ./QtScrcpy/res/i18n/zh_CN.ts \ No newline at end of file