Commit 7313d34d authored by Lukas Appelhans's avatar Lukas Appelhans

Translations for akabeicore

parent 96f1cc0b
......@@ -56,6 +56,7 @@ add_subdirectory(lib)
add_subdirectory(tools)
add_subdirectory(etc)
add_subdirectory(docs)
add_subdirectory(translations)
include(UseDoxygen)
......
#!/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
......@@ -25,6 +25,8 @@
#include <QDir>
#include <QFutureWatcher>
#include <QVariant>
#include <QTranslator>
#include <QCoreApplication>
#include <libarchive++/archivehandler.h>
#include <akabeihook.h>
......@@ -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);
......
......@@ -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
*/
......
# 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
#!/bin/bash
for arg in "de"
do
po2ts translations/akabeicore_$arg.po akabeicore_$arg.ts
done
exit
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment