From 1ae8663decb3163b92d32b80cefb46eb678a5af6 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Thu, 2 Dec 2021 01:25:46 +0800 Subject: Add i18n Support 1. Remove Qt Linguist. 2. Add GNU gettext libraries. 3. Modified source codes to meet with i18n support. --- src/ui/help/AboutDialog.cpp | 89 +++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 44 deletions(-) (limited to 'src/ui/help/AboutDialog.cpp') diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp index 4c6c2348..cd0010a6 100644 --- a/src/ui/help/AboutDialog.cpp +++ b/src/ui/help/AboutDialog.cpp @@ -1,7 +1,7 @@ /** - * This file is part of GPGFrontend. + * This file is part of GpgFrontend. * - * GPGFrontend is free software: you can redistribute it and/or modify + * GpgFrontend is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. @@ -23,8 +23,8 @@ */ #include "ui/help/AboutDialog.h" -#include "GpgFrontendBuildInfo.h" +#include "GpgFrontendBuildInfo.h" #include "rapidjson/document.h" #include "rapidjson/writer.h" @@ -33,16 +33,16 @@ using namespace rapidjson; namespace GpgFrontend::UI { AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : QDialog(parent) { - this->setWindowTitle(tr("About ") + qApp->applicationName()); + this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName()); auto* tabWidget = new QTabWidget; auto* infoTab = new InfoTab(); auto* translatorsTab = new TranslatorsTab(); updateTab = new UpdateTab(); - tabWidget->addTab(infoTab, tr("General")); - tabWidget->addTab(translatorsTab, tr("Translators")); - tabWidget->addTab(updateTab, tr("Update")); + tabWidget->addTab(infoTab, _("General")); + tabWidget->addTab(translatorsTab, _("Translators")); + tabWidget->addTab(updateTab, _("Update")); connect(tabWidget, &QTabWidget::currentChanged, this, [&](int index) { qDebug() << "Current Index" << index; }); @@ -73,20 +73,21 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) { "

" + qApp->applicationName() + "

" + "
" + qApp->applicationVersion() + "
" + "
" + GIT_VERSION + "
" + - tr("
GPGFrontend is an easy-to-use, compact, cross-platform, " - "
" - "and installation-free gpg front-end tool.
" - "It visualizes most of the common operations of gpg commands.
" - "It's licensed under the GPL v3

" - "Developer:
" - "Saturneric

" - "If you have any questions or suggestions, raise an issue
" - "at GitHub " - "or send a mail to my mailing list at eric@bktus.com.") + - tr("

Built with Qt ") + qVersion() + tr(" and GPGME ") + - GpgFrontend::GpgContext::getGpgmeVersion().c_str() + tr("
Built at ") + - BUILD_TIMESTAMP + "
"); + _("
GpgFrontend is an easy-to-use, compact, cross-platform, " + "
" + "and installation-free gpg front-end tool.
" + "It visualizes most of the common operations of gpg commands.
" + "It's licensed under the GPL v3

" + "Developer:
" + "Saturneric

" + "If you have any questions or suggestions, raise an issue
" + "at GitHub " + "or send a mail to my mailing list at eric@bktus.com.") + + "

" + _("Built with Qt") + " " + qVersion() + " " + + _("and GPGME") + " " + + GpgFrontend::GpgContext::getGpgmeVersion().c_str() + "
" + + _("Built at") + " " + BUILD_TIMESTAMP + "
"); auto* layout = new QGridLayout(); auto* pixmapLabel = new QLabel(); @@ -128,18 +129,20 @@ UpdateTab::UpdateTab(QWidget* parent) { QString::number(VERSION_PATCH); auto tipsLabel = new QLabel(); - tipsLabel->setText("
" + - tr("It is recommended that you always check the version " - "of GpgFrontend and upgrade to the latest version.") + - "

" + - tr("New versions not only represent new features, but " - "also often represent functional and security fixes.") + - "
"); + tipsLabel->setText( + "
" + + QString(_("It is recommended that you always check the version " + "of GpgFrontend and upgrade to the latest version.")) + + "

" + + _("New versions not only represent new features, but " + "also often represent functional and security fixes.") + + "
"); tipsLabel->setWordWrap(true); currentVersionLabel = new QLabel(); - currentVersionLabel->setText("
" + tr("Current Version: ") + "" + - currentVersion + "
"); + currentVersionLabel->setText("
" + QString(_("Current Version")) + + _(": ") + "" + currentVersion + + "
"); currentVersionLabel->setWordWrap(true); latestVersionLabel = new QLabel(); @@ -148,13 +151,13 @@ UpdateTab::UpdateTab(QWidget* parent) { upgradeLabel = new QLabel(); upgradeLabel->setText( "
" + - tr("The current version is inconsistent with the latest version on " - "github.") + - "

" + - tr("Please click here " - "to download the latest version.") + - "
"); + QString( + _("The current version is inconsistent with the latest version on " + "github.")) + + "
" + _("Please click") + + " here " + + _("to download the latest version.") + "
"); upgradeLabel->setWordWrap(true); upgradeLabel->setOpenExternalLinks(true); upgradeLabel->setHidden(true); @@ -192,8 +195,7 @@ void UpdateTab::getLatestVersion() { request.setUrl(QUrl(baseUrl)); QNetworkReply* replay = manager->get(request); auto thread = QThread::create([replay, this]() { - while (replay->isRunning()) - QApplication::processEvents(); + while (replay->isRunning()) QApplication::processEvents(); emit replyFromUpdateServer(replay->readAll()); }); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); @@ -209,8 +211,8 @@ void UpdateTab::processReplyDataFromUpdateServer(const QByteArray& data) { if (d.Parse(data.constData()).HasParseError() || !d.IsObject()) { qDebug() << "VersionCheckThread Found Network Error"; auto latestVersion = "Unknown"; - latestVersionLabel->setText("
" + - tr("Latest Version From Github: ") + + latestVersionLabel->setText(QString("
") + + _("Latest Version From Github") + ": " + latestVersion + "
"); return; } @@ -228,11 +230,10 @@ void UpdateTab::processReplyDataFromUpdateServer(const QByteArray& data) { latestVersion = "Unknown"; latestVersionLabel->setText("
" + - tr("Latest Version From Github: ") + + QString(_("Latest Version From Github")) + ": " + latestVersion + "
"); - if (latestVersion > currentVersion) - upgradeLabel->setHidden(false); + if (latestVersion > currentVersion) upgradeLabel->setHidden(false); } } // namespace GpgFrontend::UI -- cgit v1.2.3