[PATCH 1 of 5] Switch to resource based loading of translations
Wald Commits
scm-commit at wald.intevation.org
Thu Apr 17 10:55:31 CEST 2014
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# 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 <QtPlugin>
#include <QMessageBox>
#include <QSettings>
+#include <QTranslator>
+#include <QDebug>
#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 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/l10n">
+ <file alias="administrator_de_DE.qm">@CMAKE_CURRENT_BINARY_DIR@/administrator_de_DE.qm</file>
+</qresource>
+</RCC>
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 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE TS>
-<TS version="2.1" language="de">
-<context>
- <name>AdministratorWindow</name>
- <message>
- <location filename="../administratorwindow.cpp" line="49"/>
- <source>Menu</source>
- <translation>Menü</translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="51"/>
- <source>Create Installer</source>
- <translation>Installationspaket erstellen</translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="52"/>
- <source>Settings</source>
- <translation>Einstellungen</translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="54"/>
- <source>Help</source>
- <translation>Hilfe</translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="55"/>
- <source>About</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="57"/>
- <source>Quit</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="79"/>
- <source>Managed Certificates</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="102"/>
- <source>Administrator Application</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="113"/>
- <source>Save</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="115"/>
- <source>Load</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="117"/>
- <source>Add</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="119"/>
- <source>Remove</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="144"/>
- <source>Select certificate file</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../administratorwindow.cpp" line="165"/>
- <source>Select certificate</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-<context>
- <name>CertificateTabelModel</name>
- <message>
- <location filename="../certificatetablemodel.cpp" line="16"/>
- <source>Subject CN</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetablemodel.cpp" line="17"/>
- <source>Subject O</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetablemodel.cpp" line="18"/>
- <source>Issuer CN</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetablemodel.cpp" line="19"/>
- <source>Issuer O</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetablemodel.cpp" line="20"/>
- <source>valid from</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetablemodel.cpp" line="21"/>
- <source>valid to</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetablemodel.cpp" line="22"/>
- <source>SHA1 Fingerprint</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-<context>
- <name>CertificateTableDelegate</name>
- <message>
- <location filename="../certificatetabledelegate.cpp" line="51"/>
- <source>add</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificatetabledelegate.cpp" line="54"/>
- <source>remove</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-<context>
- <name>CreateCertListDialog</name>
- <message>
- <location filename="../createcertlistdialog.cpp" line="21"/>
- <source>adminstrator - Create signed certificate list</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createcertlistdialog.cpp" line="35"/>
- <source>Create a new, signed certificate list.
-</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createcertlistdialog.cpp" line="63"/>
- <source>Create List</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createcertlistdialog.cpp" line="81"/>
- <source>Select certificate</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createcertlistdialog.cpp" line="88"/>
- <source>Select target location</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-<context>
- <name>CreateInstallerDialog</name>
- <message>
- <location filename="../createinstallerdialog.cpp" line="21"/>
- <source>adminstrator - Create signed installer binary</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createinstallerdialog.cpp" line="36"/>
- <source>Create a new signed installer binary.
-</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createinstallerdialog.cpp" line="75"/>
- <source>Create Installer</source>
- <translation type="unfinished">Installationspaket erstellen</translation>
- </message>
- <message>
- <location filename="../createinstallerdialog.cpp" line="93"/>
- <source>Select certificate</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createinstallerdialog.cpp" line="100"/>
- <source>Select source archive</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../createinstallerdialog.cpp" line="107"/>
- <source>Select target location</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-<context>
- <name>QObject</name>
- <message>
- <location filename="../certificate.cpp" line="75"/>
- <source>Certificate:
- <bold>%1</bold>
- %2, %3
-
-Serial number:
-%4
-Valid from: <bold>%5</bold> to <bold>%6</bold>
-
-Issued by: ..</source>
- <translation type="unfinished"></translation>
- </message>
- <message>
- <location filename="../certificate.cpp" line="129"/>
- <source>Failed to parse certificate</source>
- <translation type="unfinished"></translation>
- </message>
-</context>
-</TS>
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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="de">
+<context>
+ <name>AdministratorWindow</name>
+ <message>
+ <location filename="../administratorwindow.cpp" line="49"/>
+ <source>Menu</source>
+ <translation>Menü</translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="51"/>
+ <source>Create Installer</source>
+ <translation>Installationspaket erstellen</translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="52"/>
+ <source>Settings</source>
+ <translation>Einstellungen</translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="54"/>
+ <source>Help</source>
+ <translation>Hilfe</translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="55"/>
+ <source>About</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="57"/>
+ <source>Quit</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="79"/>
+ <source>Managed Certificates</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="102"/>
+ <source>Administrator Application</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="113"/>
+ <source>Save</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="115"/>
+ <source>Load</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="117"/>
+ <source>Add</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="119"/>
+ <source>Remove</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="144"/>
+ <source>Select certificate file</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../administratorwindow.cpp" line="165"/>
+ <source>Select certificate</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>CertificateTabelModel</name>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="16"/>
+ <source>Subject CN</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="17"/>
+ <source>Subject O</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="18"/>
+ <source>Issuer CN</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="19"/>
+ <source>Issuer O</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="20"/>
+ <source>valid from</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="21"/>
+ <source>valid to</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetablemodel.cpp" line="22"/>
+ <source>SHA1 Fingerprint</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>CertificateTableDelegate</name>
+ <message>
+ <location filename="../certificatetabledelegate.cpp" line="51"/>
+ <source>add</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificatetabledelegate.cpp" line="54"/>
+ <source>remove</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>CreateCertListDialog</name>
+ <message>
+ <location filename="../createcertlistdialog.cpp" line="21"/>
+ <source>adminstrator - Create signed certificate list</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createcertlistdialog.cpp" line="35"/>
+ <source>Create a new, signed certificate list.
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createcertlistdialog.cpp" line="63"/>
+ <source>Create List</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createcertlistdialog.cpp" line="81"/>
+ <source>Select certificate</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createcertlistdialog.cpp" line="88"/>
+ <source>Select target location</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>CreateInstallerDialog</name>
+ <message>
+ <location filename="../createinstallerdialog.cpp" line="21"/>
+ <source>adminstrator - Create signed installer binary</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createinstallerdialog.cpp" line="36"/>
+ <source>Create a new signed installer binary.
+</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createinstallerdialog.cpp" line="75"/>
+ <source>Create Installer</source>
+ <translation type="unfinished">Installationspaket erstellen</translation>
+ </message>
+ <message>
+ <location filename="../createinstallerdialog.cpp" line="93"/>
+ <source>Select certificate</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createinstallerdialog.cpp" line="100"/>
+ <source>Select source archive</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../createinstallerdialog.cpp" line="107"/>
+ <source>Select target location</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="../certificate.cpp" line="75"/>
+ <source>Certificate:
+ <bold>%1</bold>
+ %2, %3
+
+Serial number:
+%4
+Valid from: <bold>%5</bold> to <bold>%6</bold>
+
+Issued by: ..</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="../certificate.cpp" line="129"/>
+ <source>Failed to parse certificate</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
More information about the Trustbridge-commits
mailing list