Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add multilingual support
Browse files Browse the repository at this point in the history
zsien committed Mar 31, 2023
1 parent 4647cae commit 3c0da20
Showing 10 changed files with 435 additions and 13 deletions.
13 changes: 13 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -78,6 +78,19 @@ configure_file(
install_dir: systemd_user_unit_dir,
)

translationSourceFiles = files([
'translations/dde-cooperation_en_US.ts',
'translations/dde-cooperation_zh_CN.ts',
'translations/dde-cooperation_zh_HK.ts',
'translations/dde-cooperation_zh_TW.ts',
])
translations = qt5.compile_translations(
ts_files: translationSourceFiles,
build_by_default: true,
install: true,
install_dir: datadir / 'dde-cooperation' / 'translations',
)

install_data('misc/org.deepin.dde.cooperation.desktop',
install_dir: join_paths(datadir, 'applications'))

4 changes: 2 additions & 2 deletions src/dde-cooperation/Android/qml/NewDevice.qml
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@ Rectangle {

ColumnLayout {
Label {
text: qsTr("使用“统信UOS助手”App扫码投屏")
text: qsTr("Scan with UnionTech OS Assistant")
}

Label {
text: qsTr("首次连接需要通过USB连接手机与电脑")
text: qsTr("Connect your phone to the computer via a USB cable for the first time")
}

Canvas {
6 changes: 3 additions & 3 deletions src/dde-cooperation/ConfirmDialog.cc
Original file line number Diff line number Diff line change
@@ -27,15 +27,15 @@ ConfirmDialog::ConfirmDialog(const QString &ip, const QString &machineName)
font.setBold(true);
font.setPixelSize(16);
m_titleLabel->setFont(font);
m_titleLabel->setText(tr("Cooperation request confirm:"));
m_titleLabel->setText(tr("PC Collaboration"));
addContent(m_titleLabel, Qt::AlignTop | Qt::AlignHCenter);

QString content = QString(tr("Machine(%1) %2 request cooperation")).arg(ip).arg(machineName);
QString content = QString(tr(R"RAW("%1" is requesting a connection to your device)RAW")).arg(ip);
m_contentLabel->setText(content);
addContent(m_contentLabel, Qt::AlignBottom | Qt::AlignHCenter);

QStringList btnTexts;
btnTexts << tr("reject") << tr("accept");
btnTexts << tr("Decline") << tr("Accept");
addButtons(btnTexts);

connect(this, &ConfirmDialog::buttonClicked, this, [=](int index, const QString &text) {
12 changes: 6 additions & 6 deletions src/dde-cooperation/Machine/Machine.cc
Original file line number Diff line number Diff line change
@@ -424,7 +424,7 @@ void Machine::handlePairResponseAux(const PairResponse &resp) {
// send notification
QString msgBody;
if (agree) {
msgBody = QString(QObject::tr("Successfully connected to %1"))
msgBody = QString(QObject::tr(R"RAW(Successfully connected to "%1")RAW"))
.arg(QString::fromStdString(m_name));
} else {
msgBody = QString(QObject::tr("Your connection request has been declined"));
@@ -623,10 +623,10 @@ void Machine::handleFsSendFileRequest(const FsSendFileRequest &req) {
std::string fileName = path.substr(iPos, path.length() - iPos);
QString msgBody;
if (exitStatus == QProcess::NormalExit) {
msgBody = QString(QObject::tr("Successfully received the file sent by device %1"))
msgBody = QString(QObject::tr(R"RAW(Successfully received files from "%1")RAW"))
.arg(QString::fromStdString(m_name));
} else {
msgBody = QString(QObject::tr("Unable to receive the file sent by device A %1"))
msgBody = QString(QObject::tr(R"RAW(Failed to receive files from "%1")RAW"))
.arg(QString::fromStdString(m_name));
}

@@ -643,10 +643,10 @@ void Machine::handleFsSendFileRequest(const FsSendFileRequest &req) {
void Machine::handleFsSendFileResult(const FsSendFileResult &resp) {
QString msgBody;
if (resp.result()) {
msgBody = QString(QObject::tr("File successfully sent to the collaboration device %1"))
msgBody = QString(QObject::tr(R"RAW(Successfully sent to "%1")RAW"))
.arg(QString::fromStdString(m_name));
} else {
msgBody = QString(QObject::tr("Unable to send files to the cooperating device %1"))
msgBody = QString(QObject::tr(R"RAW(Failed to send files to"%1")RAW"))
.arg(QString::fromStdString(m_name));
}

@@ -846,7 +846,7 @@ void Machine::receivedUserConfirm(bool accepted) {
// send notification
if (accepted) {
QString msgBody;
msgBody = QString(QObject::tr("Successfully connected to %1"))
msgBody = QString(QObject::tr(R"RAW(Successfully connected to "%1")RAW"))
.arg(QString::fromStdString(m_name));
sendReceivedFilesSystemNtf(msgBody);
}
2 changes: 1 addition & 1 deletion src/dde-cooperation/ReconnectDialog.cc
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ ReconnectDialog::ReconnectDialog(const QString &machineName)
titleLabel->setText(tr("PC Collaboration:"));
addContent(titleLabel, Qt::AlignTop | Qt::AlignHCenter);

QString content = QString(tr("Failed to connect to %1")).arg(machineName);
QString content = QString(tr(R"RAW(Failed to connect to "%1")RAW")).arg(machineName);
auto *contentLabel = new QLabel(this);
contentLabel->setText(content);
addContent(contentLabel, Qt::AlignBottom | Qt::AlignHCenter);
3 changes: 2 additions & 1 deletion src/dde-cooperation/main.cc
Original file line number Diff line number Diff line change
@@ -21,7 +21,8 @@ int main(int argc, char *argv[]) {
DApplication::setQuitOnLastWindowClosed(false);
DApplication app(argc, argv);
app.setOrganizationName("deepin");
app.setApplicationName("DDE Cooperation");
app.setApplicationName("dde-cooperation");
app.loadTranslator();

Manager cooperation(dataDir);

102 changes: 102 additions & 0 deletions translations/dde-cooperation_en_US.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en_US">
<context>
<name>ConfirmDialog</name>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="30"/>
<source>PC Collaboration</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="33"/>
<source>&quot;%1&quot; is requesting a connection to your device</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="38"/>
<source>Decline</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="38"/>
<source>Accept</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>NewDevice</name>
<message>
<location filename="../src/dde-cooperation/Android/qml/NewDevice.qml" line="13"/>
<source>Scan with UnionTech OS Assistant</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Android/qml/NewDevice.qml" line="17"/>
<source>Connect your phone to the computer via a USB cable for the first time</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="427"/>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="849"/>
<source>Successfully connected to &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="430"/>
<source>Your connection request has been declined</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="626"/>
<source>Successfully received files from &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="629"/>
<source>Failed to receive files from &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="646"/>
<source>Successfully sent to &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="649"/>
<source>Failed to send files to&quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="895"/>
<source>PC Collaboration</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ReconnectDialog</name>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="19"/>
<source>PC Collaboration:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="22"/>
<source>Failed to connect to &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="28"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="28"/>
<source>Try Again</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
102 changes: 102 additions & 0 deletions translations/dde-cooperation_zh_CN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>ConfirmDialog</name>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="30"/>
<source>PC Collaboration</source>
<translation>电脑协同</translation>
</message>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="33"/>
<source>&quot;%1&quot; is requesting a connection to your device</source>
<translation>“%1”请求协同连接至本设备</translation>
</message>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="38"/>
<source>Decline</source>
<translation>拒 绝</translation>
</message>
<message>
<location filename="../src/dde-cooperation/ConfirmDialog.cc" line="38"/>
<source>Accept</source>
<translation>接 受</translation>
</message>
</context>
<context>
<name>NewDevice</name>
<message>
<location filename="../src/dde-cooperation/Android/qml/NewDevice.qml" line="13"/>
<source>Scan with UnionTech OS Assistant</source>
<translation>使用“统信助手”App扫码投屏</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Android/qml/NewDevice.qml" line="17"/>
<source>Connect your phone to the computer via a USB cable for the first time</source>
<translation>首次连接需要通过USB连接手机与电脑</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="427"/>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="849"/>
<source>Successfully connected to &quot;%1&quot;</source>
<translation>已成功协同连接至“%1”</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="430"/>
<source>Your connection request has been declined</source>
<translation>您的协同连接请求已被拒绝</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="626"/>
<source>Successfully received files from &quot;%1&quot;</source>
<translation>成功接收到“%1”发送的文件</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="629"/>
<source>Failed to receive files from &quot;%1&quot;</source>
<translation>无法接收到“%1”发送的文件</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="646"/>
<source>Successfully sent to &quot;%1&quot;</source>
<translation>成功发送文件至协同设备“%1”</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="649"/>
<source>Failed to send files to&quot;%1&quot;</source>
<translation>无法发送文件至协同设备“%1”</translation>
</message>
<message>
<location filename="../src/dde-cooperation/Machine/Machine.cc" line="895"/>
<source>PC Collaboration</source>
<translation>电脑协同</translation>
</message>
</context>
<context>
<name>ReconnectDialog</name>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="19"/>
<source>PC Collaboration:</source>
<translation>电脑协同:</translation>
</message>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="22"/>
<source>Failed to connect to &quot;%1&quot;</source>
<translation>无法协同连接至“%1”</translation>
</message>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="28"/>
<source>Cancel</source>
<translation>取 消</translation>
</message>
<message>
<location filename="../src/dde-cooperation/ReconnectDialog.cc" line="28"/>
<source>Try Again</source>
<translation>重 试</translation>
</message>
</context>
</TS>
Loading

0 comments on commit 3c0da20

Please sign in to comment.