Skip to content
Permalink
Browse files

Initial translation support

Includes el and en_GB translations
  • Loading branch information
tatokis committed Nov 24, 2019
1 parent f353bf6 commit edef4edafc9c2a32a49e3b81914e9667502ed8d1
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
xmlstarlet sel --template --value-of "//translation[not(@type)]" "$1"
echo ""
@@ -3,16 +3,16 @@
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -279,6 +279,31 @@ if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/image.qrc")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/image.qrc" "</qresource>\n</RCC>\n")
endif ()

find_package(Qt5LinguistTools CONFIG REQUIRED)

# Generate translation.qrc
# Note that the qm files haven't been generated yet
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/translation.qrc")
file(GLOB qt_translations RELATIVE "${CMAKE_CURRENT_LIST_DIR}/resources/translations" "${CMAKE_CURRENT_LIST_DIR}/resources/translations/*.ts")
message(STATUS "Generating translation.qrc")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/translation.qrc" "<RCC>\n<qresource prefix=\"/translations\">\n")
foreach (qt_ts_translation IN LISTS qt_translations)
string(REPLACE ".ts" ".qm" qt_qm_translation ${qt_ts_translation})
message(STATUS "Importing ${qt_qm_translation}")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translation.qrc" "<file>${qt_qm_translation}</file>\n")
endforeach ()
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/translation.qrc" "</qresource>\n</RCC>\n")
endif ()

# Generate binary translations and update ts files if needed
file(GLOB qt_translations_rel RELATIVE "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_CURRENT_LIST_DIR}/resources/translations/*.ts")
qt5_add_translation(QM_FILES "${qt_translations_rel}")

# Simple target to call lupdate on demand
add_custom_target(lupdate
COMMAND Qt5::lupdate "." "-ts" ${qt_translations_rel}
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")

if (MACOS)
# Import macOS icon
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/ckb-next.icns")
@@ -358,7 +383,9 @@ if (MACOS OR LINUX)
PRIVATE
"${CMAKE_CURRENT_BINARY_DIR}/binary.qrc"
"${CMAKE_CURRENT_BINARY_DIR}/text.qrc"
"${CMAKE_CURRENT_BINARY_DIR}/image.qrc")
"${CMAKE_CURRENT_BINARY_DIR}/image.qrc"
"${CMAKE_CURRENT_BINARY_DIR}/translation.qrc"
"${QM_FILES}")
endif ()

# Declare target's include paths
@@ -23,14 +23,14 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
_anim(anim), lastDuration(1.0)
{
ui->setupUi(this);
setWindowTitle(anim->scriptName() + " Animation");
setWindowTitle(anim->scriptName() + tr(" Animation"));
ui->animName->setText(anim->name());
const AnimScript* script = anim->script();

// Build settings UI
int row = 1;
ui->settingsGrid->addItem(new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), row++, 6);
ui->settingsGrid->addWidget(new QLabel("<b>Animation</b>", this), row++, 0, 1, 7);
ui->settingsGrid->addWidget(new QLabel(tr("<b>Animation</b>"), this), row++, 0, 1, 7);
ui->settingsGrid->addWidget(hLine(), row++, 0, 1, 7);
bool rSpacePlaced = false;
QListIterator<AnimScript::Param> i(script->paramIterator());
@@ -200,32 +200,32 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
}
// Add playback info at bottom
ui->settingsGrid->addItem(new QSpacerItem(0, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), row++, 6);
ui->settingsGrid->addWidget(new QLabel("<b>Playback</b>", this), row++, 0, 1, 7);
ui->settingsGrid->addWidget(new QLabel(tr("<b>Playback</b>"), this), row++, 0, 1, 7);
ui->settingsGrid->addWidget(hLine(), row++, 0, 1, 7);
if(script->hasParam("duration")){
// Show duration spinner (if allowed)
lastDuration = anim->parameter("duration").toDouble();
ui->settingsGrid->addWidget(new QLabel("Duration:", this), row, 1);
ui->settingsGrid->addWidget(new QLabel(tr("Duration:"), this), row, 1);
QDoubleSpinBox* spinner = new QDoubleSpinBox(this);
spinner->setDecimals(1);
spinner->setMinimum(0.1);
spinner->setValue(lastDuration);
connect(spinner, SIGNAL(valueChanged(double)), this, SLOT(newDuration(double)));
settingWidgets["duration"] = spinner;
ui->settingsGrid->addWidget(spinner, row, 3, 1, 1);
ui->settingsGrid->addWidget(new QLabel("seconds", this), row, 4, 1, 2);
ui->settingsGrid->addWidget(new QLabel(tr("seconds"), this), row, 4, 1, 2);
row++;
}
// Show boxes for start with mode/with keypress
QCheckBox* check = new QCheckBox("Start with mode", this);
QCheckBox* check = new QCheckBox(tr("Start with mode"), this);
check->setChecked(anim->parameter("trigger").toBool());
ui->settingsGrid->addWidget(check, row, 3, 1, 4);
settingWidgets["trigger"] = check;
connect(check, &QCheckBox::stateChanged, [=] () {
emit updateParam("trigger");
});
row++;
check = new QCheckBox("Start with key press", this);
check = new QCheckBox(tr("Start with key press"), this);
check->setChecked(anim->parameter("kptrigger").toBool());
ui->settingsGrid->addWidget(check, row, 3, 1, 2);
settingWidgets["kptrigger"] = check;
@@ -237,14 +237,14 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
int selected = anim->parameter("kpmode").toInt();
if(script->hasKeypress()){
// If the script supports keypresses, show the option to handle them that way (default)
combo->addItem("on pressed key");
combo->addItem("on whole keyboard");
combo->addItem("on keyboard (once)");
combo->addItem(tr("on pressed key"));
combo->addItem(tr("on whole keyboard"));
combo->addItem(tr("on keyboard (once)"));
} else {
selected--;
// Otherwise, just show the choice of whether to start it every time or just once
combo->addItem("every time");
combo->addItem("only once");
combo->addItem(tr("every time"));
combo->addItem(tr("only once"));
}
if(selected < 0 || selected > combo->count())
selected = 0;
@@ -282,7 +282,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
ui->kpRepeatBox->setValue(anim->parameter("kprepeat").toDouble());
// If repeat is enabled, add repeat counts as integer values
// Mode repeat
ui->timeGrid->addWidget(new QLabel("Repeat:", this), 4, 1);
ui->timeGrid->addWidget(new QLabel(tr("Repeat:"), this), 4, 1);
QSpinBox* spinner = new QSpinBox(this);
spinner->setMinimum(0);
spinner->setMaximum(1000000);
@@ -292,9 +292,9 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
emit updateParam("stop");
});
ui->timeGrid->addWidget(spinner, 4, 3);
ui->timeGrid->addWidget(new QLabel("times", this), 4, 4);
ui->timeGrid->addWidget(new QLabel(tr("times"), this), 4, 4);
// KP repeat
ui->timeGrid->addWidget(new QLabel("Repeat:", this), 12, 1);
ui->timeGrid->addWidget(new QLabel(tr("Repeat:"), this), 12, 1);
spinner = new QSpinBox(this);
spinner->setMinimum(0);
spinner->setMaximum(1000000);
@@ -304,12 +304,12 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
emit updateParam("kpstop");
});
ui->timeGrid->addWidget(spinner, 12, 3);
ui->timeGrid->addWidget(new QLabel("times", this), 12, 4);
ui->timeGrid->addWidget(new QLabel(tr("times"), this), 12, 4);
// Infinite repeat toggles
stopCheck = new QCheckBox("Forever", this);
stopCheck = new QCheckBox(tr("Forever"), this);
stopCheck->setChecked(anim->parameter("stop").toInt() < 0);
ui->timeGrid->addWidget(stopCheck, 4, 5);
kpStopCheck = new QCheckBox("Forever", this);
kpStopCheck = new QCheckBox(tr("Forever"), this);
connect(stopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
kpStopCheck->setChecked(anim->parameter("kpstop").toInt() < 0);
ui->timeGrid->addWidget(kpStopCheck, 12, 5);
@@ -339,7 +339,7 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
emit updateParam("stop");
});
ui->timeGrid->addWidget(spinner, 4, 3);
ui->timeGrid->addWidget(new QLabel("seconds", this), 4, 4);
ui->timeGrid->addWidget(new QLabel(tr("seconds"), this), 4, 4);
// KP stop time
spinner = new QDoubleSpinBox(this);
spinner->setDecimals(1);
@@ -355,13 +355,13 @@ AnimSettingDialog::AnimSettingDialog(QWidget* parent, KbAnim* anim) :
emit updateParam("kpstop");
});
ui->timeGrid->addWidget(spinner, 12, 3);
ui->timeGrid->addWidget(new QLabel("seconds", this), 12, 4);
ui->timeGrid->addWidget(new QLabel(tr("seconds"), this), 12, 4);
// Infinite run toggles
stopCheck = new QCheckBox("Stop after:", this);
stopCheck = new QCheckBox(tr("Stop after:"), this);
stopCheck->setChecked(stop > 0.);
ui->timeGrid->addWidget(stopCheck, 4, 1);
connect(stopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
kpStopCheck = new QCheckBox("Stop after:", this);
kpStopCheck = new QCheckBox(tr("Stop after:"), this);
kpStopCheck->setChecked(kpstop > 0.);
ui->timeGrid->addWidget(kpStopCheck, 12, 1);
connect(kpStopCheck, SIGNAL(clicked()), this, SLOT(updateStops()));
@@ -20,7 +20,7 @@
<enum>Qt::ClickFocus</enum>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string notr="true">Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
@@ -52,7 +52,7 @@ void CkbUpdaterDialog::on_remindMeLaterButton_clicked(){
void CkbUpdaterDialog::on_updateButton_clicked(){
ui->remindMeLaterButton->setEnabled(false);
ui->updateButton->setEnabled(false);
ui->updateButton->setText("Downloading");
ui->updateButton->setText(tr("Downloading"));
if(_manager != nullptr)
return;

@@ -99,14 +99,14 @@ void CkbUpdaterDialog::downloadFinished(QNetworkReply* reply){
}
reply->deleteLater();

QMessageBox::information(this, "Download Complete", QString(tr("Update has been downloaded to /tmp/ckb-next/v")
QMessageBox::information(this, tr("Download Complete"), tr("Update has been downloaded to /tmp/ckb-next/v")
+ _version + suffix
#ifndef Q_OS_MAC
+ tr("<br />You will need to manually compile the source code.")
#endif
+ tr("<br /><br />Optionally, for added security, please check that the following value exists at the bottom of <a href=\"https://github.com/ckb-next/ckb-next/releases/tag/v")
+ _version
+ tr("\">this page</a>.<br /><pre>%1</pre><br />Press OK to continue.")).arg(QString(hash.result().toHex())));
+ tr("\">this page</a>.<br /><pre>%1</pre><br />Press OK to continue.").arg(QString(hash.result().toHex())));
QProcess process;
#if defined(Q_OS_MAC)
// Unmount any old ckb-next volume that might exist
@@ -72,7 +72,7 @@
</font>
</property>
<property name="text">
<string>ckb-next v</string>
<string notr="true">ckb-next v</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignHCenter</set>
@@ -118,7 +118,7 @@
<item>
<widget class="QLabel" name="changelogLabel">
<property name="text">
<string>&lt;a href=&quot;#&quot; style=&quot;text-decoration: none;&quot;&gt;v0.3.2 changelog&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;#&quot; style=&quot;text-decoration: none;&quot;&gt;v0.3.2 manual download&lt;/a&gt;</string>
<string notr="true">&lt;a href=&quot;#&quot; style=&quot;text-decoration: none;&quot;&gt;v0.3.2 changelog&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;#&quot; style=&quot;text-decoration: none;&quot;&gt;v0.3.2 manual download&lt;/a&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
@@ -44,7 +44,7 @@ void ColorButton::updateImage(){
if(!_color.isValid()){
setIcon(QIcon());
if(_setLabel)
setText("Change color...");
setText(tr("Change color..."));
return;
}
const int w = 24, h = _bigIcons ? 24 : 12;
@@ -98,11 +98,11 @@ void ExtraSettingsWidget::on_animScanButton_clicked(){
AnimScript::scan();
int count = AnimScript::count();
if(count == 0)
ui->animCountLabel->setText("No animations found");
ui->animCountLabel->setText(tr("No animations found"));
else if(count == 1)
ui->animCountLabel->setText("1 animation found");
ui->animCountLabel->setText(tr("1 animation found"));
else
ui->animCountLabel->setText(QString("%1 animations found").arg(count));
ui->animCountLabel->setText(tr("%1 animations found").arg(count));
}

void ExtraSettingsWidget::on_fpsBox_valueChanged(int arg1){
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Application Settings</string>
<string notr="true">Application Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
@@ -146,7 +146,7 @@
<item>
<widget class="QLabel" name="animPathLabel">
<property name="text">
<string>/path/to/animations</string>
<string notr="true">/path/to/animations</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@@ -94,7 +94,7 @@ int FwUpgradeDialog::exec(){
// If a blob was already specified, check its version and validity
float newV = verifyFw(blob, productID);
if(newV == 0.f){
QMessageBox::warning(parentWidget(), "Error", "<center>Not a valid firmware for this device.</center>");
QMessageBox::warning(parentWidget(), tr("Error"), tr("<center>Not a valid firmware for this device.</center>"));
return QDialog::Rejected;
}
ui->newLabel->setText(QString::number(newV, 'f', 2));
@@ -110,21 +110,21 @@ int FwUpgradeDialog::exec(){
float newV = verifyFw(blob, productID);
if(newV == 0.f){
hide();
QMessageBox::warning(parentWidget(), "Error", "<center>There was a problem with the downloaded file.<br />Please try again later.</center>");
QMessageBox::warning(parentWidget(), tr("Error"), tr("<center>There was a problem with the downloaded file.<br />Please try again later.</center>"));
return QDialog::Rejected;
}
}
// Save temporary file
if(saveBlob().isEmpty()){
hide();
QMessageBox::warning(parentWidget(), "Error", "<center>Unable to save temporary file.</center>");
QMessageBox::warning(parentWidget(), tr("Error"), tr("<center>Unable to save temporary file.</center>"));
return QDialog::Rejected;
}
// Set up UI
ui->progressBar->setValue(0);
ui->progressBar->setMaximum(1);
ui->progressBar->setTextVisible(false);
ui->statusLabel->setText("Ready to install new firmware.<br /><br /><b>Disclaimer:</b> ckb-next is not endorsed by Corsair.<br />This is <i>unlikely</i> to cause any damage, however the developers of this software do not accept any responsibility in such an event.");
ui->statusLabel->setText(tr("Ready to install new firmware.<br /><br /><b>Disclaimer:</b> ckb-next is not endorsed by Corsair.<br />This is <i>unlikely</i> to cause any damage, however the developers of this software do not accept any responsibility in such an event."));
ui->cancelButton->setEnabled(true);
ui->actionButton->setEnabled(true);
setFixedSize(DIALOG_WIDTH, DIALOG_HEIGHT_MAX);
@@ -154,10 +154,10 @@ void FwUpgradeDialog::fwUpdateProgress(int current, int total){
void FwUpgradeDialog::fwUpdateFinished(bool succeeded){
cleanBlob();
if(succeeded)
ui->statusLabel->setText("Update successful!");
ui->statusLabel->setText(tr("Update successful!"));
else
ui->statusLabel->setText("Update failed.");
ui->actionButton->setText("OK");
ui->statusLabel->setText(tr("Update failed."));
ui->actionButton->setText(tr("OK"));
ui->actionButton->setEnabled(true);
ui->progressBar->setMaximum(1);
ui->progressBar->setValue(1);
@@ -182,8 +182,8 @@ void FwUpgradeDialog::on_actionButton_clicked(){
ui->progressBar->setTextVisible(true);
ui->cancelButton->hide();
ui->actionButton->setEnabled(false);
ui->actionButton->setText("Please wait");
ui->statusLabel->setText("Installing firmware...");
ui->actionButton->setText(tr("Please wait"));
ui->statusLabel->setText(tr("Installing firmware..."));
kb->fwUpdate(savePath);
} else {
// Finished, close dialog.
@@ -90,14 +90,14 @@
<item row="1" column="2">
<widget class="QLabel" name="curLabel">
<property name="text">
<string>0.00</string>
<string notr="true">0.00</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLabel" name="newLabel">
<property name="text">
<string>0.00</string>
<string notr="true">0.00</string>
</property>
</widget>
</item>

0 comments on commit edef4ed

Please sign in to comment.
You can’t perform that action at this time.