Skip to content

Commit

Permalink
Support translations for strings from libopenrazer
Browse files Browse the repository at this point in the history
  • Loading branch information
z3ntu committed Jun 1, 2024
1 parent c949eb4 commit 8c0c213
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/devicewidget/ledwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "util.h"

#include <QApplication>
#include <QColorDialog>
#include <QComboBox>
#include <QHBoxLayout>
Expand All @@ -22,7 +23,8 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)
auto *verticalLayout = new QVBoxLayout(this);

// Set appropriate text
QLabel *lightingLocationLabel = new QLabel(tr("Effect %1").arg(libopenrazer::ledIdToStringTable.value(led->getLedId(), "error")));
QString lightingLocation = qApp->translate("libopenrazer", libopenrazer::ledIdToStringTable.value(led->getLedId(), "error"));
QLabel *lightingLocationLabel = new QLabel(tr("Effect %1").arg(lightingLocation));

auto *lightingHBox = new QHBoxLayout();
verticalLayout->addWidget(lightingLocationLabel);
Expand Down Expand Up @@ -51,7 +53,7 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)
// Add items from capabilities
for (auto ledFx : libopenrazer::ledFxList) {
if (led->hasFx(ledFx.getIdentifier())) {
comboBox->addItem(ledFx.getDisplayString(), QVariant::fromValue(ledFx));
comboBox->addItem(qApp->translate("libopenrazer", ledFx.getDisplayString()), QVariant::fromValue(ledFx));
// Set selection to current effect
if (ledFx.getIdentifier() == currentEffect) {
comboBox->setCurrentIndex(comboBox->count() - 1);
Expand Down
7 changes: 6 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ int main(int argc, char *argv[])
QString translationsDirectory = QString(RAZERGENIE_DATADIR) + "/translations/";
#endif
bool ret = translator.load(QLocale::system(), QString(), QString(), translationsDirectory);
qDebug() << "Translation loaded:" << ret;
qDebug() << "RazerGenie translation loaded:" << ret;
app.installTranslator(&translator);

QTranslator libopenrazerTranslator;
ret = libopenrazer::loadTranslations(&libopenrazerTranslator);
qDebug() << "libopenrazer translations loaded:" << ret;
app.installTranslator(&libopenrazerTranslator);

RazerGenie w;
w.show();

Expand Down

0 comments on commit 8c0c213

Please sign in to comment.