From 2cf16c698bb4c0395e8b7e82d1d30a17f9c935e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Panzenb=C3=B6ck?= Date: Mon, 24 Feb 2014 01:32:56 +0100 Subject: [PATCH] actually load the translation --- CMakeLists.txt | 3 ++- src/config.h.in | 1 + src/main.cpp | 9 +++++++++ translations/qjoypad_de.ts | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b77fc7..660819b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ add_definitions(${QT_DEFINITIONS}) # for config.h include_directories("${PROJECT_BINARY_DIR}/src") -file(GLOB qjoypad_TRANS_SOURCES translations/qjoypad_*.ts) +file(GLOB qjoypad_TRANS_SOURCES translations/qjoypad*.ts) if(UPDATE_TRANSLATIONS) file(GLOB_RECURSE qjoypad_TRANS_FILES *.cpp *.h) @@ -63,6 +63,7 @@ add_subdirectory(icons) add_subdirectory(src) add_custom_target(translations_target DEPENDS ${qjoypad_TRANS}) +add_dependencies(qjoypad translations_target) install(PROGRAMS qjoypad.desktop DESTINATION "share/applications") install(FILES ${qjoypad_TRANS} DESTINATION "share/qjoypad/translations") diff --git a/src/config.h.in b/src/config.h.in index 2a142f3..ecccddf 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,6 +11,7 @@ #define QJOYPAD_ICON24 "@CMAKE_INSTALL_PREFIX@/share/icons/hicolor/24x24/apps/qjoypad.png" #define QJOYPAD_ICON64 "@CMAKE_INSTALL_PREFIX@/share/icons/hicolor/64x64/apps/qjoypad.png" +#define QJOYPAD_L10N_DIR "@CMAKE_INSTALL_PREFIX@/share/qjoypad/translations/" #cmakedefine WITH_LIBUDEV diff --git a/src/main.cpp b/src/main.cpp index 5935bc8..4bb7c7a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include //to load layouts #include "layout.h" @@ -48,8 +49,16 @@ int main( int argc, char **argv ) //create a new event loop. This will be captured by the QApplication //when it gets created QApplication app( argc, argv ); + QTranslator translator; app.setQuitOnLastWindowClosed(false); + if (translator.load(QLocale::system(), "qjoypad", "_", QJOYPAD_L10N_DIR)) { + app.installTranslator(&translator); + } + else { + debug_mesg("no translation for locale: %s\n", qPrintable(QLocale::system().name())); + } + //where QJoyPad saves its settings! const QString settingsDir(QDir::homePath() + "/.qjoypad3/"); diff --git a/translations/qjoypad_de.ts b/translations/qjoypad_de.ts index 191df36..f83f4bd 100644 --- a/translations/qjoypad_de.ts +++ b/translations/qjoypad_de.ts @@ -146,7 +146,7 @@ &Rapid Fire - Schnellfeue&r + &Schnellfeuer