From 51b5c517de53e867c0bcadba1d9736f73e264b1b Mon Sep 17 00:00:00 2001 From: Lubos Dolezel Date: Tue, 2 Jun 2015 20:39:38 +0200 Subject: Localization now builds, installs and loads --- src/gui/CMakeLists.txt | 11 +++++++++++ src/gui/main.cpp | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 27eaf71..38b6c8c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -35,6 +35,15 @@ qt4_wrap_ui( qt4_add_resources(twinkle_QRC icons.qrc) +qt4_add_translation(twinkle_LANG + lang/twinkle_cs.ts + lang/twinkle_de.ts + lang/twinkle_fr.ts + lang/twinkle_nl.ts + lang/twinkle_ru.ts + lang/twinkle_sv.ts +) + qt4_wrap_cpp(twinkle_MOC gui.h dtmfform.h @@ -130,6 +139,7 @@ set(TWINKLE_GUI-SRCS ${twinkle_UIS} ${twinkle_QRC} ${twinkle_MOC} + ${twinkle_LANG} ) add_executable(twinkle ${TWINKLE_GUI-SRCS}) @@ -139,3 +149,4 @@ target_link_libraries(twinkle -lpthread -lresolv ${LibMagic_LIBRARY} ${LIBXML2_L ${Boost_LIBRARIES} Qt4::QtGui Qt4::Qt3Support ${ALSA_LIBRARY}) install(TARGETS twinkle DESTINATION bin) +install(FILES ${twinkle_LANG} DESTINATION share/twinkle/lang) diff --git a/src/gui/main.cpp b/src/gui/main.cpp index cd0ad5b..2a89d5d 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "address_book.h" @@ -513,7 +514,11 @@ QApplication *create_user_interface(bool cli_mode, int argc, char **argv, QTrans // Do not report to memman as the translator will be deleted // automatically when the QApplication is deleted. qtranslator = new QTranslator(0); - qtranslator->load(QString("twinkle_") + QTextCodec::locale(), + + QString langName = QLocale::system().name().left(2); + + qDebug() << "Language name:" << langName; + qtranslator->load(QString("twinkle_") + langName, QString(sys_config->get_dir_lang().c_str())); qa->installTranslator(qtranslator); -- cgit v1.2.3