diff --git a/kiwix-desktop.pro b/kiwix-desktop.pro index af28b3a..e90b727 100644 --- a/kiwix-desktop.pro +++ b/kiwix-desktop.pro @@ -6,6 +6,7 @@ QT += core gui QT += webenginewidgets +QT += widgets qml quick CONFIG += link_pkgconfig @@ -85,10 +86,9 @@ isEmpty(PREFIX) { target.path = $$PREFIX/bin INSTALLS += target -TRANSLATIONS = locales/kiwix-desktop_fr.ts +TRANSLATIONS = "resources/i18n/kiwix-desktop_fr.ts" CODECFORSRC = UTF-8 -QT += widgets static { PKGCONFIG_OPTION = "--static" @@ -117,4 +117,8 @@ QMAKE_CFLAGS += $$PKGCONFIG_CFLAGS LIBS += $$system(pkg-config --libs $$PKGCONFIG_OPTION kiwix) RESOURCES += \ - resources/kiwix.qrc + resources/kiwix.qrc \ + resources/translations.qrc + +system($$QMAKE_LUPDATE -locations relative -no-ui-lines $$_PRO_FILE_) +system($$QMAKE_LRELEASE $$_PRO_FILE_) diff --git a/locales/kiwix-desktop_fr.qm b/resources/i18n/kiwix-desktop_fr.qm similarity index 100% rename from locales/kiwix-desktop_fr.qm rename to resources/i18n/kiwix-desktop_fr.qm diff --git a/locales/kiwix-desktop_fr.ts b/resources/i18n/kiwix-desktop_fr.ts similarity index 99% rename from locales/kiwix-desktop_fr.ts rename to resources/i18n/kiwix-desktop_fr.ts index 53a250f..191bfe2 100644 --- a/locales/kiwix-desktop_fr.ts +++ b/resources/i18n/kiwix-desktop_fr.ts @@ -1,6 +1,6 @@ - + AboutDialog diff --git a/resources/translations.qrc b/resources/translations.qrc new file mode 100644 index 0000000..5100ea5 --- /dev/null +++ b/resources/translations.qrc @@ -0,0 +1,5 @@ + + + i18n/kiwix-desktop_fr.qm + + diff --git a/src/library.cpp b/src/library.cpp index c84d446..2647839 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1,6 +1,6 @@ #include "library.h" -#include +#include #include Library::Library() @@ -17,7 +17,7 @@ QString Library::openBook(const QString &zimPath) if(QString::fromStdString(it->second->getZimFilePath()) == zimPath) return it->first; } - qInfo() << tr("Opening") << zimPath; + qInfo() << QObject::tr("Opening") << zimPath; auto zimPath_ = zimPath.toStdString(); auto reader = std::shared_ptr(new kiwix::Reader(zimPath_)); auto id = QString::fromStdString(reader->getId() + ".zim"); diff --git a/src/main.cpp b/src/main.cpp index 1b13bfd..107a9b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include "kiwixapp.h" +#include +#include #include #include @@ -8,13 +10,18 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); KiwixApp a(argc, argv); + // format systems language + QString defaultLocale = QLocale::system().name(); // e.g. "de_DE" + defaultLocale.truncate(defaultLocale.lastIndexOf('_')); // e.g. "de" + QLocale::setDefault(defaultLocale); + QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); a.installTranslator(&qtTranslator); QTranslator myappTranslator; - myappTranslator.load("kiwix-desktop_" + QLocale::system().name()); + myappTranslator.load(":/i18n/kiwix-desktop.qm"); a.installTranslator(&myappTranslator); QCommandLineParser parser;