feat: good translate

This commit is contained in:
Barry 2022-06-08 13:59:09 +08:00
parent 9daad1aaa6
commit d3b665037d
11 changed files with 28 additions and 276 deletions

View file

@ -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;

View file

@ -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()) {

View file

@ -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;
});

View file

@ -38,7 +38,10 @@ qt5_create_translation在cmake clean的时候会删除翻译好的ts文件
上面3个方案都有一个共同问题就是翻译文件处理都是和编译绑定在一起的每次编译都会检测执行实际的翻译工作是所有
编程工作都完成以后统一执行一次lupdate、翻译、lrelease就可以了不应该和编译绑定在一起
所以写两个shell脚本lupdate.sh和lrelease.sh来处理比较合适
所以写两个shell脚本lupdate.sh和lrelease.sh来处理比较合适其实非常简单
1. 更新tslupdate -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

Binary file not shown.

View file

@ -1,46 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>Device</name>
<message>
<source>wait current file transfer to complete</source>
<translation type="vanished">wait current file transfer to complete</translation>
</message>
<message>
<source>file transfer complete</source>
<translation type="vanished">file transfer complete</translation>
</message>
<message>
<source>file transfer failed</source>
<translation type="vanished">file transfer failed</translation>
</message>
<message>
<source>install apk</source>
<translation>install apk</translation>
</message>
<message>
<source>file transfer</source>
<translation>file transfer</translation>
</message>
<message>
<source>wait current %1 to complete</source>
<translation>wait current %1 to complete</translation>
</message>
<message>
<source>%1 complete, save in %2</source>
<translation>%1 complete, save in %2</translation>
</message>
<message>
<source>%1 complete
save in %2</source>
<translation type="vanished">%1 complete\n save in %2</translation>
</message>
<message>
<source>%1 failed</source>
<translation>%1 failed</translation>
</message>
</context>
<context>
<name>Dialog</name>
<message>
@ -149,10 +109,6 @@
<source>reverse connection</source>
<translation>reverse connection</translation>
</message>
<message>
<source>auto enable</source>
<translation type="vanished">auto enable</translation>
</message>
<message>
<source>background record</source>
<translation>background record</translation>
@ -197,10 +153,6 @@
<source>device serial:</source>
<translation>device serial:</translation>
</message>
<message>
<source>Config</source>
<translation type="vanished">Config</translation>
</message>
<message>
<source>bit rate:</source>
<translation>bit rate:</translation>
@ -231,31 +183,6 @@
<source>no lock</source>
<translation>no lock</translation>
</message>
<message>
<source>warning</source>
<translatorcomment>Warning</translatorcomment>
<translation type="vanished">Warning</translation>
</message>
<message>
<source>Quit or set tray?</source>
<translatorcomment>Quit or set tray?</translatorcomment>
<translation type="vanished">Quit or set tray?</translation>
</message>
<message>
<source>Quit</source>
<translatorcomment>Quit</translatorcomment>
<translation type="vanished">Quit</translation>
</message>
<message>
<source>Set tray</source>
<translatorcomment>Set tray</translatorcomment>
<translation type="vanished">Set tray</translation>
</message>
<message>
<source>Cancel</source>
<translatorcomment>Cancel</translatorcomment>
<translation type="vanished">Cancel</translation>
</message>
<message>
<source>Notice</source>
<translatorcomment>Notice</translatorcomment>
@ -266,52 +193,12 @@
<translatorcomment>Hidden here!</translatorcomment>
<translation>Hidden here!</translation>
</message>
<message>
<source>2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InputConvertGame</name>
<message>
<source>current keymap mode: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>custom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>normal</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KeyMap</name>
<message>
<source>Script updated, current keymap mode:normal, Press ~ key to switch keymap mode</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<source>This software is completely open source and free, you can download it at the following address:</source>
<translation type="vanished">This software is completely open source and free, you can download it at the following address:</translation>
</message>
<message>
<source>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:</source>
<translation type="vanished">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:</translation>
</message>
<message>
<source>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:</source>
<translation type="vanished">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:</translation>
</message>
<message>
<source>This software is completely open source and free. Use it at your own risk. You can download it at the following address:</source>
<translation type="unfinished"></translation>
<translation>This software is completely open source and free. Use it at your own risk. You can download it at the following address:</translation>
</message>
</context>
<context>
@ -328,14 +215,6 @@ You can download it at the following address:</source>
<source>expand notify</source>
<translation>expand notify</translation>
</message>
<message>
<source>turn off</source>
<translation type="vanished">turn off</translation>
</message>
<message>
<source>turn on</source>
<translation type="vanished">turn on</translation>
</message>
<message>
<source>touch switch</source>
<translation>touch switch</translation>
@ -380,31 +259,16 @@ You can download it at the following address:</source>
<source>open screen</source>
<translation>open screen</translation>
</message>
<message>
<source>group control</source>
<translation>group control</translation>
</message>
</context>
<context>
<name>VideoForm</name>
<message>
<source>wait current file transfer to complete</source>
<translation type="vanished">wait current file transfer to complete</translation>
</message>
<message>
<source>file transfer complete</source>
<translation type="vanished">file transfer complete</translation>
</message>
<message>
<source>file transfer failed</source>
<translation type="vanished">file transfer failed</translation>
</message>
<message>
<source>file does not exist</source>
<translation>file does not exist</translation>
</message>
</context>
<context>
<name>videoForm</name>
<message>
<source>qrc:/qml/pinwheel.qml</source>
<translation type="vanished">qrc:/qml/pinwheel.qml</translation>
</message>
</context>
</TS>

Binary file not shown.

View file

@ -1,46 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>Device</name>
<message>
<source>wait current file transfer to complete</source>
<translation type="vanished"></translation>
</message>
<message>
<source>file transfer complete</source>
<translation type="vanished"></translation>
</message>
<message>
<source>file transfer failed</source>
<translation type="vanished"></translation>
</message>
<message>
<source>install apk</source>
<translation>apk</translation>
</message>
<message>
<source>file transfer</source>
<translation></translation>
</message>
<message>
<source>wait current %1 to complete</source>
<translation>%1</translation>
</message>
<message>
<source>%1 complete, save in %2</source>
<translation>%1,%2</translation>
</message>
<message>
<source>%1 complete
save in %2</source>
<translation type="vanished">%1\n %2</translation>
</message>
<message>
<source>%1 failed</source>
<translation>%1 </translation>
</message>
</context>
<context>
<name>Dialog</name>
<message>
@ -149,10 +109,6 @@
<source>reverse connection</source>
<translation></translation>
</message>
<message>
<source>auto enable</source>
<translation type="vanished"></translation>
</message>
<message>
<source>background record</source>
<translation></translation>
@ -197,10 +153,6 @@
<source>device serial:</source>
<translation></translation>
</message>
<message>
<source>Config</source>
<translation type="vanished"></translation>
</message>
<message>
<source>bit rate:</source>
<translation></translation>
@ -231,31 +183,6 @@
<source>no lock</source>
<translation></translation>
</message>
<message>
<source>warning</source>
<translatorcomment></translatorcomment>
<translation type="vanished"></translation>
</message>
<message>
<source>Quit or set tray?</source>
<translatorcomment>退</translatorcomment>
<translation type="vanished">退</translation>
</message>
<message>
<source>Quit</source>
<translatorcomment>退</translatorcomment>
<translation type="vanished">退</translation>
</message>
<message>
<source>Set tray</source>
<translatorcomment></translatorcomment>
<translation type="vanished"></translation>
</message>
<message>
<source>Cancel</source>
<translatorcomment></translatorcomment>
<translation type="vanished"></translation>
</message>
<message>
<source>Notice</source>
<translatorcomment></translatorcomment>
@ -266,32 +193,6 @@
<translatorcomment></translatorcomment>
<translation></translation>
</message>
<message>
<source>2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>InputConvertGame</name>
<message>
<source>current keymap mode: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>custom</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>normal</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>KeyMap</name>
<message>
<source>Script updated, current keymap mode:normal, Press ~ key to switch keymap mode</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
@ -314,14 +215,6 @@
<source>expand notify</source>
<translation></translation>
</message>
<message>
<source>turn off</source>
<translation type="vanished"></translation>
</message>
<message>
<source>turn on</source>
<translation type="vanished"></translation>
</message>
<message>
<source>touch switch</source>
<translation></translation>
@ -366,31 +259,16 @@
<source>open screen</source>
<translation></translation>
</message>
<message>
<source>group control</source>
<translation></translation>
</message>
</context>
<context>
<name>VideoForm</name>
<message>
<source>wait current file transfer to complete</source>
<translation type="vanished"></translation>
</message>
<message>
<source>file transfer complete</source>
<translation type="vanished"></translation>
</message>
<message>
<source>file transfer failed</source>
<translation type="vanished"></translation>
</message>
<message>
<source>file does not exist</source>
<translation></translation>
</message>
</context>
<context>
<name>videoForm</name>
<message>
<source>qrc:/qml/pinwheel.qml</source>
<translation type="vanished">qrc:/qml/pinwheel.qml</translation>
</message>
</context>
</TS>

View file

@ -324,7 +324,7 @@
</sizepolicy>
</property>
<property name="text">
<string>2</string>
<string notr="true">2</string>
</property>
</widget>
</item>

3
ci/lrelease.sh Normal file
View file

@ -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

4
ci/lupdate.sh Normal file
View file

@ -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