# HG changeset patch # User Andre Heinecke # Date 1397667659 0 # Node ID 16b6d5686835f6ebd0dbb3f0a414f7bd1ad30d3d # Parent 413b29f6758fbaa654e6b4f9d87308aa5dc8b73a Switch to resource based loading of translations diff -r 413b29f6758f -r 16b6d5686835 ui/CMakeLists.txt --- a/ui/CMakeLists.txt Wed Apr 16 16:05:46 2014 +0000 +++ b/ui/CMakeLists.txt Wed Apr 16 17:00:59 2014 +0000 @@ -112,11 +112,21 @@ qt5_add_resources(ADMINSTRATOR_SOURCES_WITH_RESOURCES ${ADMINSTRATOR_RESOURCES}) if(Qt5LinguistTools_FOUND) + # Include translation as a resource + # This works in the source directory to enable the rcc dependencies to be found + # and it also updates the currently available localization. + # This would probably be better placed in a macro + configure_file(l10n/administrator.qrc.in administrator.qrc) + qt5_add_resources(ADMINISTRATOR_L10N ${CMAKE_CURRENT_BINARY_DIR}/administrator.qrc) qt5_create_translation(ADMINISTRATOR_TRANSLATION ${ADMINSTRATOR_SOURCES_WITH_RESOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/l10n/administrator.ts) - add_executable(administrator ${ADMINSTRATOR_SOURCES_WITH_RESOURCES} ${ADMINISTRATOR_TRANSLATION}) + ${CMAKE_CURRENT_SOURCE_DIR}/l10n/administrator_de_DE.ts) + add_executable(administrator ${ADMINSTRATOR_SOURCES_WITH_RESOURCES} + ${ADMINISTRATOR_L10N} + ${ADMINISTRATOR_TRANSLATION} + ) else() - message (STATUS "WARNING: Could not find qt linguist tools. Translation will not be included.") + message (STATUS "WARNING: Could not find qt linguist tools. Translation will not be included.") + add_executable(administrator ${ADMINSTRATOR_SOURCES_WITH_RESOURCES}) endif() target_link_libraries(administrator Qt5::Widgets diff -r 413b29f6758f -r 16b6d5686835 ui/administrator.cpp --- a/ui/administrator.cpp Wed Apr 16 16:05:46 2014 +0000 +++ b/ui/administrator.cpp Wed Apr 16 17:00:59 2014 +0000 @@ -11,6 +11,8 @@ #include #include #include +#include +#include #ifndef VERSION #define VERSION "0.0.1" @@ -41,6 +43,17 @@ QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); QSettings::setDefaultFormat(QSettings::IniFormat); + QTranslator translator; + if (QLocale::system().name() == "C") { + /* Useful for testing / development as the primary target is german */ + translator.load(":/l10n/administrator_de_DE"); + } else { + translator.load(":/l10n/administrator_" + QLocale::system().name()); + qDebug() << "Loading translations for: " << "administrator_" + + QLocale::system().name(); + } + app.installTranslator(&translator); + AdministratorWindow adminWin; adminWin.show(); diff -r 413b29f6758f -r 16b6d5686835 ui/l10n/administrator.qrc.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/l10n/administrator.qrc.in Wed Apr 16 17:00:59 2014 +0000 @@ -0,0 +1,5 @@ + + + @CMAKE_CURRENT_BINARY_DIR@/administrator_de_DE.qm + + diff -r 413b29f6758f -r 16b6d5686835 ui/l10n/administrator.ts --- a/ui/l10n/administrator.ts Wed Apr 16 16:05:46 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,212 +0,0 @@ - - - - - AdministratorWindow - - - Menu - MenĂ¼ - - - - Create Installer - Installationspaket erstellen - - - - Settings - Einstellungen - - - - Help - Hilfe - - - - About - - - - - Quit - - - - - Managed Certificates - - - - - Administrator Application - - - - - Save - - - - - Load - - - - - Add - - - - - Remove - - - - - Select certificate file - - - - - Select certificate - - - - - CertificateTabelModel - - - Subject CN - - - - - Subject O - - - - - Issuer CN - - - - - Issuer O - - - - - valid from - - - - - valid to - - - - - SHA1 Fingerprint - - - - - CertificateTableDelegate - - - add - - - - - remove - - - - - CreateCertListDialog - - - adminstrator - Create signed certificate list - - - - - Create a new, signed certificate list. - - - - - - Create List - - - - - Select certificate - - - - - Select target location - - - - - CreateInstallerDialog - - - adminstrator - Create signed installer binary - - - - - Create a new signed installer binary. - - - - - - Create Installer - Installationspaket erstellen - - - - Select certificate - - - - - Select source archive - - - - - Select target location - - - - - QObject - - - Certificate: - <bold>%1</bold> - %2, %3 - -Serial number: -%4 -Valid from: <bold>%5</bold> to <bold>%6</bold> - -Issued by: .. - - - - - Failed to parse certificate - - - - diff -r 413b29f6758f -r 16b6d5686835 ui/l10n/administrator_de_DE.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/l10n/administrator_de_DE.ts Wed Apr 16 17:00:59 2014 +0000 @@ -0,0 +1,212 @@ + + + + + AdministratorWindow + + + Menu + MenĂ¼ + + + + Create Installer + Installationspaket erstellen + + + + Settings + Einstellungen + + + + Help + Hilfe + + + + About + + + + + Quit + + + + + Managed Certificates + + + + + Administrator Application + + + + + Save + + + + + Load + + + + + Add + + + + + Remove + + + + + Select certificate file + + + + + Select certificate + + + + + CertificateTabelModel + + + Subject CN + + + + + Subject O + + + + + Issuer CN + + + + + Issuer O + + + + + valid from + + + + + valid to + + + + + SHA1 Fingerprint + + + + + CertificateTableDelegate + + + add + + + + + remove + + + + + CreateCertListDialog + + + adminstrator - Create signed certificate list + + + + + Create a new, signed certificate list. + + + + + + Create List + + + + + Select certificate + + + + + Select target location + + + + + CreateInstallerDialog + + + adminstrator - Create signed installer binary + + + + + Create a new signed installer binary. + + + + + + Create Installer + Installationspaket erstellen + + + + Select certificate + + + + + Select source archive + + + + + Select target location + + + + + QObject + + + Certificate: + <bold>%1</bold> + %2, %3 + +Serial number: +%4 +Valid from: <bold>%5</bold> to <bold>%6</bold> + +Issued by: .. + + + + + Failed to parse certificate + + + +