diff --git a/CMakeLists.txt b/CMakeLists.txt index 480c9c37ff7624ecad7b8e2d3a1799da4dab8d8b..185f12d8c15b82a0be7c6560056dc91467370773 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ add_subdirectory(lib) add_subdirectory(tools) add_subdirectory(etc) add_subdirectory(docs) +add_subdirectory(translations) include(UseDoxygen) diff --git a/generateTs.sh b/generateTs.sh new file mode 100755 index 0000000000000000000000000000000000000000..72bc59ed448139b215c983b17ae4bb80c67e2da9 --- /dev/null +++ b/generateTs.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +mkdir translations/translations/ +for arg in "de" +do + lupdate lib/* -ts translations/akabeicore_$arg.ts + ts2po translations/akabeicore_$arg.ts -o translations/translations/akabeicore_$arg.po +done + +exit + diff --git a/lib/akabeibackend.cpp b/lib/akabeibackend.cpp index ef23b9578c6cf2a594de1a32a7e212b64d621acb..cdc3180b63211af5239ba478b63d3cf352d180a9 100644 --- a/lib/akabeibackend.cpp +++ b/lib/akabeibackend.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -337,6 +339,13 @@ Backend::~Backend() { } +void Backend::setLocale(const QString& locale) +{ + QTranslator * translator = new QTranslator(this); + translator->load("akabeicore_" + locale + ".qm", "/usr/share/akabeicore/translations/");//FIXME: Use translations from install dir + QCoreApplication::instance()->installTranslator(translator); +} + void Backend::initialize() { Q_D(Backend); @@ -636,7 +645,7 @@ Package* Backend::loadPackageFromFile(const QString& path) if (pkg.getEntries().contains(".INSTALL")) { retpackage->d_func()->setScriptlet(pkg.readTextFile(".INSTALL")); } - + int isize = 0; foreach (QString const& entry, pkg.getEntries()) { retpackage->d_func()->addFile(entry); diff --git a/lib/akabeibackend.h b/lib/akabeibackend.h index fe5ce8a9df698f54863b5a9de57c39bbbef1da83..d3476dca5adae48558a4803bbd02e2f1a3395e76 100644 --- a/lib/akabeibackend.h +++ b/lib/akabeibackend.h @@ -83,6 +83,11 @@ class AKABEICORESHARED_EXPORT Backend : public QObject static Backend *instance(); virtual ~Backend(); + /** + * Sets the locale for AkabeiCore. + */ + void setLocale(const QString &locale); + /** * @returns the status of the backend */ diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0faf26163134e21b94f79560820e7ba5a5acc8ff --- /dev/null +++ b/translations/CMakeLists.txt @@ -0,0 +1,44 @@ +# translation start +FIND_PROGRAM(QT_LRELEASE_EXECUTABLE + NAMES lrelease + PATHS ${QT_BINARY_DIR} + NO_DEFAULT_PATH +) + +# needed to create translation files +IF(NOT QT_LRELEASE_EXECUTABLE) + MESSAGE(FATAL_ERROR "Qt4 lrelease not found. Make sure that it has been built and installed by the Qt4 package.") +ENDIF(NOT QT_LRELEASE_EXECUTABLE) + +MACRO(ADD_TRANSLATION_FILES _sources) + FOREACH(_current_FILE ${ARGN}) + GET_FILENAME_COMPONENT(_in ${_current_FILE} ABSOLUTE) + GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE) + + SET(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.qm)# + + ADD_CUSTOM_COMMAND( + OUTPUT ${_out} + COMMAND ${QT_LRELEASE_EXECUTABLE} + ARGS -verbose ${_in} -qm ${_out} + DEPENDS ${_in} + ) + + SET(${_sources} ${${_sources}} ${_out}) + ENDFOREACH(_current_FILE) +ENDMACRO(ADD_TRANSLATION_FILES) + + +FILE(GLOB TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/akabeicore_*.ts) + +ADD_TRANSLATION_FILES(QM_FILES ${TS_FILES}) + +# creating a custom target is needed to make the files build +# "ALL" means that it will be run by default +ADD_CUSTOM_TARGET(translations ALL + DEPENDS ${QM_FILES}) + +INSTALL(CODE "MESSAGE(\"Installing AkabeiCore i18n files...\")") +INSTALL (FILES ${QM_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/share/akabeicore/translations) +# translation end diff --git a/translations/allPoToTs.sh b/translations/allPoToTs.sh new file mode 100755 index 0000000000000000000000000000000000000000..83f57b4450cca2fba500ab9f102eeea0fe2c8d39 --- /dev/null +++ b/translations/allPoToTs.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +for arg in "de" +do + po2ts translations/akabeicore_$arg.po akabeicore_$arg.ts +done + +exit