diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2012-08-15 01:04:14 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2012-08-15 01:04:14 +0200 |
commit | 8f6543355110a109878bde10b912555019af1212 (patch) | |
tree | 46609ff215496a4ea373b9eacbf8b2c30ca04237 /sowatchd | |
parent | 4e468800d7129c0adbe4bc874932f99a542c4eeb (diff) | |
download | sowatch-8f6543355110a109878bde10b912555019af1212.tar.gz sowatch-8f6543355110a109878bde10b912555019af1212.zip |
adding locale support to libsowatch
Diffstat (limited to 'sowatchd')
-rw-r--r-- | sowatchd/main.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sowatchd/main.cpp b/sowatchd/main.cpp index 67ed7ac..1fd1789 100644 --- a/sowatchd/main.cpp +++ b/sowatchd/main.cpp @@ -1,4 +1,5 @@ #include <QtCore/QDebug> +#include <QtCore/QTranslator> #include <QtGui/QApplication> #include <QtDBus/QDBusConnection> @@ -13,6 +14,30 @@ namespace sowatch using namespace sowatch; +static void setupLocalization(QApplication *app) +{ + const QString locale(QLocale::system().name()); + QTranslator *translator; + + // Set up main Qt translator first + translator = new QTranslator(app); + if (translator->load("qt_" + locale, + QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { + app->installTranslator(translator); + } else { + delete translator; + qWarning() << "Could not load Qt translation for" << locale; + } + + // Set up libsowatch translator + translator = new QTranslator(app); + if (translator->load("libsowatch_" + locale, SOWATCH_I18N_DIR)) { + app->installTranslator(translator); + } else { + qWarning() << "Could not load translation for" << locale; + } +} + int main(int argc, char *argv[]) { // Some plugins use QtGui functionality, so QApplication must be used @@ -23,6 +48,8 @@ int main(int argc, char *argv[]) QApplication::setApplicationName("sowatchd"); QApplication::setQuitOnLastWindowClosed(false); + setupLocalization(&app); + sowatch::daemon = new Daemon(&app); new DaemonAdaptor(sowatch::daemon); |