mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 19:44:59 +00:00
增加多语言
This commit is contained in:
parent
6e6075d1dc
commit
4109c4724d
11 changed files with 324 additions and 20 deletions
|
@ -148,5 +148,3 @@ linux {
|
|||
RESOURCES += \
|
||||
res.qrc
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QtScrcpy</string>
|
||||
<string notr="true">QtScrcpy</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0">
|
||||
|
@ -57,7 +57,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>:</string>
|
||||
<string notr="true">:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -137,6 +137,9 @@
|
|||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="bitRateBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -150,7 +153,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="videoSizeBox"/>
|
||||
<widget class="QComboBox" name="videoSizeBox">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QPushButton" name="startAdbdBtn">
|
||||
|
|
BIN
QtScrcpy/i18n/QtScrcpy_en.qm
Normal file
BIN
QtScrcpy/i18n/QtScrcpy_en.qm
Normal file
Binary file not shown.
128
QtScrcpy/i18n/QtScrcpy_en.ts
Normal file
128
QtScrcpy/i18n/QtScrcpy_en.ts
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US">
|
||||
<context>
|
||||
<name>Dialog</name>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="42"/>
|
||||
<source>Wireless</source>
|
||||
<translation>Wireless</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="87"/>
|
||||
<source>wireless connect</source>
|
||||
<translation>wireless connect</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="94"/>
|
||||
<source>wireless disconnect</source>
|
||||
<translation>wireless disconnect</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="104"/>
|
||||
<source>USB line</source>
|
||||
<translation>USB line</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="113"/>
|
||||
<source>stop server</source>
|
||||
<translation>stop server</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="120"/>
|
||||
<source>start server</source>
|
||||
<translation>start server</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="127"/>
|
||||
<source>device serial:</source>
|
||||
<translation>device serial:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="134"/>
|
||||
<source>bit rate:</source>
|
||||
<translation>bit rate:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="151"/>
|
||||
<source>video size:</source>
|
||||
<translation>video size:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="165"/>
|
||||
<source>start adbd</source>
|
||||
<translation>start adbd</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="172"/>
|
||||
<source>get device ip</source>
|
||||
<translation>get device ip</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="179"/>
|
||||
<source>update device</source>
|
||||
<translation>update device</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ToolForm</name>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="14"/>
|
||||
<source>Tool</source>
|
||||
<translation>Tool</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="20"/>
|
||||
<source>full screen</source>
|
||||
<translation>full screen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="43"/>
|
||||
<source>turn off</source>
|
||||
<translation>turn off</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="53"/>
|
||||
<source>turn on</source>
|
||||
<translation>turn on</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="63"/>
|
||||
<source>volume up</source>
|
||||
<translation>volume up</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="73"/>
|
||||
<source>volume down</source>
|
||||
<translation>volume down</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="83"/>
|
||||
<source>app switch</source>
|
||||
<translation>app switch</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="93"/>
|
||||
<source>menu</source>
|
||||
<translation>menu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="103"/>
|
||||
<source>home</source>
|
||||
<translation>home</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="113"/>
|
||||
<source>return</source>
|
||||
<translation>return</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>videoForm</name>
|
||||
<message>
|
||||
<location filename="../videoform.ui" line="75"/>
|
||||
<source>qrc:/qml/pinwheel.qml</source>
|
||||
<translation>qrc:/qml/pinwheel.qml</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
BIN
QtScrcpy/i18n/QtScrcpy_zh.qm
Normal file
BIN
QtScrcpy/i18n/QtScrcpy_zh.qm
Normal file
Binary file not shown.
128
QtScrcpy/i18n/QtScrcpy_zh.ts
Normal file
128
QtScrcpy/i18n/QtScrcpy_zh.ts
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
<context>
|
||||
<name>Dialog</name>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="42"/>
|
||||
<source>Wireless</source>
|
||||
<translation>无线</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="87"/>
|
||||
<source>wireless connect</source>
|
||||
<translation>无线连接</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="94"/>
|
||||
<source>wireless disconnect</source>
|
||||
<translation>无线断开</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="104"/>
|
||||
<source>USB line</source>
|
||||
<translation>USB线</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="113"/>
|
||||
<source>stop server</source>
|
||||
<translation>停止服务</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="120"/>
|
||||
<source>start server</source>
|
||||
<translation>启动服务</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="127"/>
|
||||
<source>device serial:</source>
|
||||
<translation>设备序列号:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="134"/>
|
||||
<source>bit rate:</source>
|
||||
<translation>比特率:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="151"/>
|
||||
<source>video size:</source>
|
||||
<translation>视频尺寸:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="165"/>
|
||||
<source>start adbd</source>
|
||||
<translation>启动adbd</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="172"/>
|
||||
<source>get device ip</source>
|
||||
<translation>获取设备IP</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../dialog.ui" line="179"/>
|
||||
<source>update device</source>
|
||||
<translation>刷新设备列表</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ToolForm</name>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="14"/>
|
||||
<source>Tool</source>
|
||||
<translation>工具</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="20"/>
|
||||
<source>full screen</source>
|
||||
<translation>全屏</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="43"/>
|
||||
<source>turn off</source>
|
||||
<translation>锁屏</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="53"/>
|
||||
<source>turn on</source>
|
||||
<translation>解锁</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="63"/>
|
||||
<source>volume up</source>
|
||||
<translation>音量加</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="73"/>
|
||||
<source>volume down</source>
|
||||
<translation>音量减</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="83"/>
|
||||
<source>app switch</source>
|
||||
<translation>切换应用</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="93"/>
|
||||
<source>menu</source>
|
||||
<translation>菜单</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="103"/>
|
||||
<source>home</source>
|
||||
<translation>主界面</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../toolform.ui" line="113"/>
|
||||
<source>return</source>
|
||||
<translation>返回</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>videoForm</name>
|
||||
<message>
|
||||
<location filename="../videoform.ui" line="75"/>
|
||||
<source>qrc:/qml/pinwheel.qml</source>
|
||||
<translation>qrc:/qml/pinwheel.qml</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -2,6 +2,7 @@
|
|||
#include <QDebug>
|
||||
#include <QTcpSocket>
|
||||
#include <QTcpServer>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "dialog.h"
|
||||
#include "decoder.h"
|
||||
|
@ -10,6 +11,7 @@ Dialog* g_mainDlg = Q_NULLPTR;
|
|||
|
||||
QtMessageHandler g_oldMessageHandler = Q_NULLPTR;
|
||||
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
void installTranslator();
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -21,6 +23,8 @@ int main(int argc, char *argv[])
|
|||
Decoder::init();
|
||||
QApplication a(argc, argv);
|
||||
|
||||
installTranslator();
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qputenv("QTSCRCPY_ADB_PATH", "../../../third_party/adb/win/adb.exe");
|
||||
qputenv("QTSCRCPY_SERVER_PATH", "../../../third_party/scrcpy-server.jar");
|
||||
|
@ -50,6 +54,24 @@ int main(int argc, char *argv[])
|
|||
return ret;
|
||||
}
|
||||
|
||||
void installTranslator() {
|
||||
static QTranslator translator;
|
||||
QLocale locale;
|
||||
QLocale::Language language = locale.language();
|
||||
QString languagePath = ":i18n/";
|
||||
switch (language) {
|
||||
case QLocale::Chinese:
|
||||
languagePath += "QtScrcpy_zh.qm";
|
||||
break;
|
||||
case QLocale::English:
|
||||
default:
|
||||
languagePath += "QtScrcpy_en.qm";
|
||||
}
|
||||
|
||||
translator.load(languagePath);
|
||||
qApp->installTranslator(&translator);
|
||||
}
|
||||
|
||||
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
if (g_oldMessageHandler) {
|
||||
|
|
|
@ -6,5 +6,7 @@
|
|||
<file>res/phone-v.png</file>
|
||||
<file>qml/pinwheel.qml</file>
|
||||
<file>qml/images/pinwheel.png</file>
|
||||
<file>i18n/QtScrcpy_en.qm</file>
|
||||
<file>i18n/QtScrcpy_zh.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="fullScreenBtn">
|
||||
<property name="toolTip">
|
||||
<string>full screen</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -36,6 +39,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="powerBtn">
|
||||
<property name="toolTip">
|
||||
<string>turn off</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -43,6 +49,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="turnOnBtn">
|
||||
<property name="toolTip">
|
||||
<string>turn on</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -50,6 +59,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="volumeUpBtn">
|
||||
<property name="toolTip">
|
||||
<string>volume up</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -57,6 +69,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="volumeDownBtn">
|
||||
<property name="toolTip">
|
||||
<string>volume down</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -64,6 +79,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="appSwitchBtn">
|
||||
<property name="toolTip">
|
||||
<string>app switch</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -71,6 +89,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="menuBtn">
|
||||
<property name="toolTip">
|
||||
<string>menu</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -78,6 +99,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="homeBtn">
|
||||
<property name="toolTip">
|
||||
<string>home</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
@ -85,6 +109,9 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="returnBtn">
|
||||
<property name="toolTip">
|
||||
<string>return</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
|
|
|
@ -11,21 +11,8 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string/>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>110</y>
|
||||
<width>93</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
7
all.pro
7
all.pro
|
@ -1,2 +1,7 @@
|
|||
TEMPLATE = subdirs
|
||||
SUBDIRS = QtScrcpy
|
||||
SUBDIRS = QtScrcpy
|
||||
|
||||
# 多语言翻译文件
|
||||
TRANSLATIONS = \
|
||||
$$PWD/QtScrcpy/res/i18n/QtScrcpy_zh.ts \
|
||||
$$PWD/QtScrcpy/res/i18n/QtScrcpy_en.ts
|
||||
|
|
Loading…
Add table
Reference in a new issue