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 zcmX|7S!fec6upyelF5dsC{^Qw>W5Zh6jW=wJsmx$+XDucyrG=_uTXDyULTZPRuBB z-^qPrJ5eA`p3y}_!5-q5H{$+6e4C5N{f79CB$2n8rk9oyg}%_@$(^WsDV47wa*R;A z>L8J`lk&|E!Ed6rIctE&xSIFR;Cqu>8Ho|OZg35cP7`r{?)KqRM80L*i>DP-BL9oiSiK{Tdv;*olII9=DKOmi2mu-b-)igeG76qdoQc9}Pbhw;IHgD> zlNgRp39=|pA{nFr8N(&u&6Fh#n1!QJ3pgE!LYeWt96BVsM+7DVP1qg^Me*MV?=e3M zl?WFG51n#Fh{{%Z+sLp7?y_5&$}~6$^70UQT&3X_?E$K7GiGMt5#<31uo}Lyql&&H zu(DdV!n*R-gR?uHQi~=t^@Nod4TY&Dll11SrdW#B!t|_?0hco*g^3xNB@9K0 zvPKg+i-{I%0mbxuh8e24E6SSm9FxQhlL2YED37bGl)@6ars;V#lVqYS8;WVx@|ezV x-n28VI3%l72+iXbRv@Z@*g0&q{AeBFEgRAP2M#6;J(oqujAiIrsXe^G@ehVA?5_X- delta 940 zcmZXQYe-XZ7{;Hoxt;Co24xqV>7g1?is2$_CAc(-BFGP2p{(OPvr}`E?aWnBON*kk z$e@CVk|2l@E3Al$ibA`GVA2JGY~5%TT1{i7rwROJDmi+ReV=LB*@M)N zH|F|~)rKAHDB=K{9#<~tvEu)fy(VOu3{h<^7-z_MDLU-ULffLUz2wvU6S ziJf~d)A1(p-IUi98pTiVuQQ2z;*SM2ynUAPITJV-mKyH^a-La!8}o@Pw)(v)-&a_b zJ|-qf*7%CAG;mC^m0V;!E)|>}%LH|)u;LAk-k1EnCPS|&}aWVYatWa=4h`!Lj6X^&sPK+o1JbS zH?{q8p6SnJg3DcUs*8HJOIx2J@2N{Wl}E#mTwBuBH0X6*N%j*U?sUD}O{YSxMpc)Q zyOqF$QpgA(f(A4q1Qj|@F>5g>XyU&N4Pkyg@LDptnt8@}O65SLp)sWDYOx$snp9Z} z%O0CaW0w16sP_#^)ElR?6?A$(mHVkIP~Xd$(3xGWFBzprK5iBcP;ogmFbvua0> zN?DI8;aE_O4kwHrG99B@;nYx){uS=GAuG3O;h3(3LbB4hVYs*qi6Of>RRP3lAj;8U z!ZImj^3s{tf2n2J?u4T0av&a!s$pH`mip*OHm-k%b>|wMNZldlB%%AMYnI^;K9ABw 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 zcmWlVZAepb6vm&s`|{uJz1u$Yims~|1Ub?QtR@TRilQixvM?&ctk$Gj$Yim|QTa($ z%tE3UP(mq6j95iTnO25DMzIFvr*OT&f(1rVg!K67aL#$o^LzgP0jt-OT9lA}Kz*>WnPSUWToZf$zy0xk}R8GT6bwO300k^0X*ZR5Nt?sg)^TA!n>;U|G{-KewUF~AdP&VE z2KuK5UeH&4uE)>nytj-)=n7xo&6XQvcRnnj7T(GIzKo#{e;R_+}A-)9zFG zItDCr4`q0-42J>Jlxe7^x6799Q4)R4H|(MrdWUz%OFahv*%_2tOR}z3=-x&-*;T{@7tt&vu_G z9O(N;0k|SyHc|k1D-hcetjB=(H30M&kQ-G1#0{~dX#lz;*t7K}_G@s$YXwldpgQ3! z)^+gKK1bdd_;>9EP%Tr|WfV^p@CoCKFSmxFDHk{`$-_B%V1!9kh@BuJhlAG`a1@eji zaW^JdB*R?~(0McY8o!KATgi{r37of+pLyk2^;%nI92ywVmRnw<&VcrhIu?y|vv!Mw z_z_loi!Vne*v67|G|C={g8~bNrA~ATb274i zsqxPUW=JmcSB67k!BSaC@lNb5T3i5wU!*x%aMab-yCg+Q6dJ@PNs!%w*+PQ*Y^h0h zNK{aT3#x!nn%rd$aarU#MW5`Fj&Fu*rH%s|1;WM4A+X+wI6?7i24g}UBzht 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