From 53ac6e5a53f00034d85bce8edd057b3baf20d659 Mon Sep 17 00:00:00 2001 From: Edric Milaret <edric.ladent-milaret@savoirfairelinux.com> Date: Mon, 14 Sep 2015 13:37:06 -0400 Subject: [PATCH] i18n: make the win client translation ready Issue: #80359 Change-Id: I87f674050c1345dd75699505b5ea57a4de5a4961 --- RingWinClient.pro | 29 ++++++++++++++++++++++++++++- aboutdialog.cpp | 7 +++---- aboutdialog.ui | 2 +- accountdetails.cpp | 4 ++-- callwidget.cpp | 15 ++++++++------- configurationwidget.cpp | 4 ++-- contactdelegate.cpp | 2 +- instantmessagingwidget.cpp | 6 +++--- main.cpp | 15 +++++++++++++++ mainbar.cpp | 4 ++-- ring.nsi | 5 +++++ videooverlay.cpp | 4 ++-- videoview.cpp | 6 +++--- wizarddialog.cpp | 2 +- 14 files changed, 76 insertions(+), 29 deletions(-) diff --git a/RingWinClient.pro b/RingWinClient.pro index 4df771b..c9fa80f 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -25,6 +25,10 @@ contains(BUILD, Debug) { CONFIG += console } +isEmpty(QMAKE_LRELEASE) { + QMAKE_LRELEASE = lrelease +} + SOURCES += main.cpp\ mainwindow.cpp \ callwidget.cpp \ @@ -101,6 +105,26 @@ RESOURCES += \ RC_FILE = ico.rc +TRANSLATIONS = + +maketranslationdir.target = customtarget +maketranslationdir.commands = $(MKDIR) $$OUT_PWD/share/ring/translations/ + +updateqm.input = TRANSLATIONS +updateqm.output = $$OUT_PWD/release/share/ring/translations/${QMAKE_FILE_BASE}.qm +updateqm.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm $$OUT_PWD/release/share/ring/translations/${QMAKE_FILE_BASE}.qm +updateqm.CONFIG += no_link + +QMAKE_EXTRA_TARGETS += maketranslationdir +QMAKE_EXTRA_COMPILERS += updateqm + +PRE_TARGETDEPS += customtarget compiler_updateqm_make_all + +QM_FILES.files = share +QM_FILES.path = $$OUT_PWD/release + +INSTALLS += QM_FILES + DISTFILES += \ License.rtf \ ringtones/konga.ul \ @@ -122,6 +146,9 @@ win32 { RUNTIME.files = $${RING}/bin/libring.dll $${RING}/bin/libringclient.dll RUNTIME.path = $$OUT_PWD/release + LRC_TRANSLATION.files = $${RING}/share/libringclient/translations + LRC_TRANSLATION.path = $$OUT_PWD/release/share/libringclient/ + QTRUNTIME.files = $$RUNTIMEDIR/Qt5Core.dll $$RUNTIMEDIR/Qt5Widgets.dll \ $$RUNTIMEDIR/Qt5Gui.dll $$RUNTIMEDIR/Qt5Svg.dll \ $$RUNTIMEDIR/Qt5Xml.dll @@ -145,6 +172,6 @@ win32 { $$RUNTIMEDIR/libwinpthread-1.dll LIBSTD.path = $$OUT_PWD/release - INSTALLS += RINGTONES PACKAGING LICENSE RUNTIME QTRUNTIME QTDEPSRUNTIME \ + INSTALLS += RINGTONES PACKAGING LICENSE RUNTIME LRC_TRANSLATION QTRUNTIME QTDEPSRUNTIME \ QTPLUGINIMAGE QTPLATFORMS LIBSTD } diff --git a/aboutdialog.cpp b/aboutdialog.cpp index 4551181..f5be38e 100644 --- a/aboutdialog.cpp +++ b/aboutdialog.cpp @@ -31,10 +31,9 @@ AboutDialog::AboutDialog(QWidget *parent) : this->setFixedSize(this->width(),this->height()); ui->creditsWidget->hide(); ui->clientVersionLabel->setText( - QString("<html><head/><body><p><span style=\" font-weight:600;\">Windows Ring v") - + VERSION - + "</span></p></body></html>"); - ui->gitVersionLabel->setText(QString("version: ") + GIT_VERSION); + QString("<html><head/><body><p><span style=\" font-weight:600;\">" + "%1 v%2</span></p></body></html>").arg(tr("Windows Ring"), VERSION)); + ui->gitVersionLabel->setText(QString("%1: %2").arg(tr("version"), GIT_VERSION)); } AboutDialog::~AboutDialog() diff --git a/aboutdialog.ui b/aboutdialog.ui index c0f6a3e..116f605 100644 --- a/aboutdialog.ui +++ b/aboutdialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>674</width> - <height>534</height> + <height>565</height> </rect> </property> <property name="sizePolicy"> diff --git a/accountdetails.cpp b/accountdetails.cpp index a9873f3..b4c1afe 100644 --- a/accountdetails.cpp +++ b/accountdetails.cpp @@ -40,14 +40,14 @@ AccountDetails::AccountDetails(QWidget *parent) : setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); ui->audioCodecView->setColumnCount(4); - QStringList audioHeader {"Enabled", "Name", "Bitrate", "Samplerate"}; + QStringList audioHeader {tr("Enabled"), tr("Name"), tr("Bitrate"), tr("Samplerate")}; ui->audioCodecView->setHorizontalHeaderLabels(audioHeader); ui->audioCodecView->verticalHeader()->hide(); ui->audioCodecView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->audioCodecView->setShowGrid(false); ui->videoCodecView->setColumnCount(3); - QStringList videoHeader {"Enabled", "Name", "Bitrate"}; + QStringList videoHeader {tr("Enabled"), tr("Name"), tr("Bitrate")}; ui->videoCodecView->setHorizontalHeaderLabels(videoHeader); ui->videoCodecView->verticalHeader()->hide(); ui->videoCodecView->setSelectionBehavior(QAbstractItemView::SelectRows); diff --git a/callwidget.cpp b/callwidget.cpp index 705e2e7..3293b7e 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -120,13 +120,13 @@ CallWidget::CallWidget(QWidget *parent) : ContactMethod* contactMethod = ui->historyList->currentIndex() .data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>(); - auto copyAction = new QAction("Copy number", this); + auto copyAction = new QAction(tr("Copy number"), this); menu.addAction(copyAction); connect(copyAction, &QAction::triggered, [=]() { QApplication::clipboard()->setText(contactMethod->uri()); }); if (not contactMethod->contact() || contactMethod->contact()->isPlaceHolder()) { - auto addExisting = new QAction("Add to contact", this); + auto addExisting = new QAction(tr("Add to contact"), this); menu.addAction(addExisting); connect(addExisting, &QAction::triggered, [=]() { ContactPicker contactPicker(contactMethod); @@ -171,13 +171,13 @@ CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec if ((Account::Protocol)protocol.toUInt() == Account::Protocol::RING) { auto username = idx.data(static_cast<int>(Account::Role::Username)); ui->ringIdLabel->setText( - "Your Ring ID: " + username.toString()); + QString("%1: %2").arg(tr("Your RingID"), username.toString())); found = true; return; } } if (not found){ - ui->ringIdLabel->setText("NO RING ACCOUNT FOUND"); + ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND")); } } @@ -241,7 +241,7 @@ CallWidget::findRingAccount() account->displayName() = account->alias(); auto username = account->username(); ui->ringIdLabel->setText( - "Your Ring ID: " + username); + QString("%1: %2").arg(tr("Your RingID"), username)); found = true; return; } @@ -257,7 +257,7 @@ void CallWidget::callIncoming(Call *call) { if (!call->account()->isAutoAnswer()) { - ui->callLabel->setText("Call from " + call->formattedName()); + ui->callLabel->setText(QString("%1 %2").arg(tr("Call from"), call->formattedName())); ui->callInvite->setVisible(true); ui->callInvite->raise(); } @@ -315,7 +315,8 @@ CallWidget::callStateChanged(Call* call, Call::State previousState) displaySpinner(false); ui->videoWidget->show(); } - ui->callStateLabel->setText("Call State : " + call->toHumanStateName()); + ui->callStateLabel->setText(QString("%1: %2") + .arg(tr("Call State"), call->toHumanStateName())); } void diff --git a/configurationwidget.cpp b/configurationwidget.cpp index b7162df..ad5eed9 100644 --- a/configurationwidget.cpp +++ b/configurationwidget.cpp @@ -168,7 +168,7 @@ ConfigurationWidget::on_deleteAccountButton_clicked() void ConfigurationWidget::on_addAccountButton_clicked() { - auto account = accountModel_->add("New Account", + auto account = accountModel_->add(tr("New Account"), ui->accountTypeBox->model()->index( ui->accountTypeBox->currentIndex(), 0)); account->setRingtonePath(Utils::GetRingtonePath()); @@ -199,7 +199,7 @@ ConfigurationWidget::on_clearHistoryButton_clicked() { QMessageBox confirmationDialog; - confirmationDialog.setText("Are you sure you want to clear all your history?"); + confirmationDialog.setText(tr("Are you sure you want to clear all your history?")); confirmationDialog.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); auto ret = confirmationDialog.exec(); diff --git a/contactdelegate.cpp b/contactdelegate.cpp index c8f0565..009d102 100644 --- a/contactdelegate.cpp +++ b/contactdelegate.cpp @@ -86,7 +86,7 @@ ContactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->drawText(QRect(rect.left()+sizeImage_+5, rect.top() + rect.height()/2, rect.width(), rect.height()/2), - opt.displayAlignment, "<Multiple contact methods>"); + opt.displayAlignment, tr("<Multiple contact methods>")); break; } } diff --git a/instantmessagingwidget.cpp b/instantmessagingwidget.cpp index 7cf1893..f64c662 100644 --- a/instantmessagingwidget.cpp +++ b/instantmessagingwidget.cpp @@ -39,15 +39,15 @@ InstantMessagingWidget::InstantMessagingWidget(QWidget *parent) : imDelegate_ = new ImDelegate(); ui->messageOutput->setItemDelegate(imDelegate_); ui->messageOutput->setContextMenuPolicy(Qt::ActionsContextMenu); - auto copyAction = new QAction("Copy", this); + auto copyAction = new QAction(tr("Copy"), this); ui->messageOutput->addAction(copyAction); connect(copyAction, &QAction::triggered, [=]() { copyToClipboard(); }); - auto displayDate = new QAction("Display date", this); + auto displayDate = new QAction(tr("Display date"), this); displayDate->setCheckable(true); ui->messageOutput->addAction(displayDate); - auto displayAuthor = new QAction("Display author", this); + auto displayAuthor = new QAction(tr("Display author"), this); displayAuthor->setCheckable(true); ui->messageOutput->addAction(displayAuthor); auto lamdba = [=](){ diff --git a/main.cpp b/main.cpp index 2da8d3b..590f6f0 100644 --- a/main.cpp +++ b/main.cpp @@ -28,6 +28,8 @@ #include <iostream> #include <QThread> +#include <QTranslator> +#include <QLibraryInfo> #ifdef Q_OS_WIN32 #include <windows.h> @@ -66,6 +68,19 @@ main(int argc, char *argv[]) Console(); } + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + a.installTranslator(&qtTranslator); + + QTranslator lrcTranslator; + lrcTranslator.load("share/libringclient/translations/lrc_" + QLocale::system().name()); + a.installTranslator(&lrcTranslator); + + QTranslator mainTranslator; + mainTranslator.load("share/ring/translations/ring_client_windows_" + QLocale::system().name()); + a.installTranslator(&mainTranslator); + QFont font; font.setFamily("Segoe UI"); a.setFont(font); diff --git a/mainbar.cpp b/mainbar.cpp index 46351d8..45f4973 100644 --- a/mainbar.cpp +++ b/mainbar.cpp @@ -29,11 +29,11 @@ MainBar::MainBar(QWidget *parent) : { ui->setupUi(this); - auto aboutAction = new QAction("About", this); + auto aboutAction = new QAction(tr("About"), this); menu_->addAction(aboutAction); connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAboutDialog())); - auto exitAction = new QAction("Exit", this); + auto exitAction = new QAction(tr("Exit"), this); menu_->addAction(exitAction); connect(exitAction, SIGNAL(triggered()), this, SLOT(on_exitButton_clicked())); diff --git a/ring.nsi b/ring.nsi index 9be84c2..4f2c35b 100644 --- a/ring.nsi +++ b/ring.nsi @@ -70,6 +70,10 @@ section "install" file imageformats/* setOutPath $INSTDIR\ringtones file ringtones/* + setOutPath $INSTDIR\share\ring\translations + file share/ring/translations/* + setOutPath $INSTDIR\share\libringclient\translations + file share/libringclient/translations/* # Uninstaller - See function un.onInit and section "uninstall" for configuration writeUninstaller "$INSTDIR\uninstall.exe" @@ -129,6 +133,7 @@ section "uninstall" rmDir /r $INSTDIR\platforms rmDir /r $INSTDIR\imageformats rmDir /r $INSTDIR\ringtones + rmDir /r $INSTDIR\share # Always delete uninstaller as the last action delete $INSTDIR\uninstall.exe diff --git a/videooverlay.cpp b/videooverlay.cpp index c3bcc79..3ab2f80 100644 --- a/videooverlay.cpp +++ b/videooverlay.cpp @@ -33,14 +33,14 @@ VideoOverlay::VideoOverlay(QWidget *parent) : setAttribute(Qt::WA_NoSystemBackground); menu_ = new QMenu(this); - auto muteAudio = new QAction("Mute Audio", this); + auto muteAudio = new QAction(tr("Mute Audio"), this); muteAudio->setCheckable(true); connect(muteAudio, &QAction::triggered, [=](bool) { actionModel_->execute(UserActionModel::Action::MUTE_AUDIO); }); menu_->addAction(muteAudio); - auto muteVideo = new QAction("Mute Video", this); + auto muteVideo = new QAction(tr("Mute Video"), this); muteVideo->setCheckable(true); connect(muteVideo, &QAction::triggered, [=](bool) { actionModel_->execute(UserActionModel::Action::MUTE_VIDEO); diff --git a/videoview.cpp b/videoview.cpp index c907530..c43b995 100644 --- a/videoview.cpp +++ b/videoview.cpp @@ -181,18 +181,18 @@ VideoView::showContextMenu(const QPoint& pos) menu.addSeparator(); - auto shareAction = new QAction("Share entire screen", this); + auto shareAction = new QAction(tr("Share entire screen"), this); menu.addAction(shareAction); connect(shareAction, &QAction::triggered, [=]() { Video::SourceModel::instance()->setDisplay(0, QApplication::desktop()->rect()); }); - auto shareAreaAction = new QAction("Share screen area", this); + auto shareAreaAction = new QAction(tr("Share screen area"), this); menu.addAction(shareAreaAction); connect(shareAreaAction, &QAction::triggered, [=]() { SelectAreaDialog selec; selec.exec(); }); - auto shareFileAction = new QAction("Share file", this); + auto shareFileAction = new QAction(tr("Share file"), this); menu.addAction(shareFileAction); connect(shareFileAction, &QAction::triggered, [=]() { QFileDialog dialog(this); diff --git a/wizarddialog.cpp b/wizarddialog.cpp index 5f73ef6..28f1fd3 100644 --- a/wizarddialog.cpp +++ b/wizarddialog.cpp @@ -58,7 +58,7 @@ void WizardDialog::accept() { //ui->spinnerLabel->show(); - ui->label->setText("Please wait while we create your account."); + ui->label->setText(tr("Please wait while we create your account.")); ui->buttonBox->setEnabled(false); ui->usernameEdit->setEnabled(false); -- GitLab