From 8f6543355110a109878bde10b912555019af1212 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Wed, 15 Aug 2012 01:04:14 +0200 Subject: adding locale support to libsowatch --- libsowatch/allwatchscanner.cpp | 4 ++++ libsowatch/allwatchscanner.h | 2 +- libsowatch/libsowatch.pro | 7 ++++++- libsowatch/libsowatch_en.ts | 31 +++++++++++++++++++++++++++++++ libsowatch/libsowatch_es.ts | 31 +++++++++++++++++++++++++++++++ libsowatch/sowatch_global.h | 21 ++++++++++++--------- metawatch/metawatchdigital.cpp | 6 +++--- metawatch/res/graphics/idle_gmail.bmp | Bin 134 -> 0 bytes metawatch/res/graphics/idle_mail.bmp | Bin 0 -> 134 bytes metawatch/res/graphics/idle_msg.bmp | Bin 0 -> 134 bytes metawatch/res/graphics/idle_sms.bmp | Bin 134 -> 0 bytes sowatchd/main.cpp | 27 +++++++++++++++++++++++++++ 12 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 libsowatch/libsowatch_en.ts create mode 100644 libsowatch/libsowatch_es.ts delete mode 100644 metawatch/res/graphics/idle_gmail.bmp create mode 100644 metawatch/res/graphics/idle_mail.bmp create mode 100644 metawatch/res/graphics/idle_msg.bmp delete mode 100644 metawatch/res/graphics/idle_sms.bmp diff --git a/libsowatch/allwatchscanner.cpp b/libsowatch/allwatchscanner.cpp index 8a49b86..97f8454 100644 --- a/libsowatch/allwatchscanner.cpp +++ b/libsowatch/allwatchscanner.cpp @@ -1,3 +1,7 @@ +#include + +#include "registry.h" +#include "watchplugininterface.h" #include "allwatchscanner.h" using namespace sowatch; diff --git a/libsowatch/allwatchscanner.h b/libsowatch/allwatchscanner.h index ac0baae..561c6a8 100644 --- a/libsowatch/allwatchscanner.h +++ b/libsowatch/allwatchscanner.h @@ -4,7 +4,7 @@ #include #include -#include +#include "watchscanner.h" namespace sowatch { diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro index 59f2eee..ce0468e 100644 --- a/libsowatch/libsowatch.pro +++ b/libsowatch/libsowatch.pro @@ -59,13 +59,18 @@ HEADERS += \ gconfkey.h \ notificationsmodel.h +TRANSLATIONS += libsowatch_en.ts libsowatch_es.ts + install_headers.files = $$HEADERS +install_translations.files = libsowatch*.qm install_headers.path = /usr/include/sowatch !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { target.path = /opt/sowatch/lib + install_translations.path = /opt/sowatch/i18n } else { target.path = /usr/lib + install_translations.path = /usr/share/sowatch/i18n } -INSTALLS += install_headers target +INSTALLS += install_headers install_translations target diff --git a/libsowatch/libsowatch_en.ts b/libsowatch/libsowatch_en.ts new file mode 100644 index 0000000..eb24692 --- /dev/null +++ b/libsowatch/libsowatch_en.ts @@ -0,0 +1,31 @@ + + + + + sowatch::Notification + + + %n second(s) ago + + %n second ago + %n seconds ago + + + + + %n minute(s) ago + + %n minute ago + %n minutes ago + + + + + %n hour(s) ago + + %n hour ago + %n hours ago + + + + diff --git a/libsowatch/libsowatch_es.ts b/libsowatch/libsowatch_es.ts new file mode 100644 index 0000000..2d19ef2 --- /dev/null +++ b/libsowatch/libsowatch_es.ts @@ -0,0 +1,31 @@ + + + + + sowatch::Notification + + + %n second(s) ago + + hace %n segundo + hace %n segundos + + + + + %n minute(s) ago + + hace %n minuto + hace %n minutos + + + + + %n hour(s) ago + + hace %n hora + hace %n horas + + + + diff --git a/libsowatch/sowatch_global.h b/libsowatch/sowatch_global.h index b537930..3e2f795 100644 --- a/libsowatch/sowatch_global.h +++ b/libsowatch/sowatch_global.h @@ -11,17 +11,20 @@ #endif #if defined(QT_SIMULATOR) || (!defined(MEEGO_VERSION_MAJOR) && !defined(Q_WS_MAEMO_5) && !defined(QT_NO_DEBUG)) -# define SOWATCH_PLUGINS_DIR ".." -# define SOWATCH_RESOURCES_DIR ".." -# define SOWATCH_QML_DIR ".." +# define SOWATCH_PLUGINS_DIR ".." +# define SOWATCH_RESOURCES_DIR ".." +# define SOWATCH_QML_DIR ".." +# define SOWATCH_I18N_DIR ".." #elif defined(MEEGO_VERSION_MAJOR) || defined(Q_WS_MAEMO_5) -# define SOWATCH_PLUGINS_DIR "/opt/sowatch/lib" -# define SOWATCH_RESOURCES_DIR "/opt/sowatch/share" -# define SOWATCH_QML_DIR "/opt/sowatch/qml" +# define SOWATCH_PLUGINS_DIR "/opt/sowatch/lib" +# define SOWATCH_RESOURCES_DIR "/opt/sowatch/share" +# define SOWATCH_QML_DIR "/opt/sowatch/qml" +# define SOWATCH_I18N_DIR "/opt/sowatch/i18n" #elif defined(Q_OS_LINUX) -# define SOWATCH_PLUGINS_DIR "/usr/lib/sowatch" -# define SOWATCH_RESOURCES_DIR "/usr/share/sowatch" -# define SOWATCH_QML_DIR SOWATCH_RESOURCES_DIR "/qml" +# define SOWATCH_PLUGINS_DIR "/usr/lib/sowatch" +# define SOWATCH_RESOURCES_DIR "/usr/share/sowatch" +# define SOWATCH_QML_DIR SOWATCH_RESOURCES_DIR "/qml" +# define SOWATCH_I18N_DIR SOWATCH_RESOURCES_DIR "/i18n" #else # error Please define the paths for your platform #endif diff --git a/metawatch/metawatchdigital.cpp b/metawatch/metawatchdigital.cpp index 3029613..abe47a9 100644 --- a/metawatch/metawatchdigital.cpp +++ b/metawatch/metawatchdigital.cpp @@ -144,8 +144,8 @@ void MetaWatchDigital::clear(Mode mode, bool black) void MetaWatchDigital::renderIdleScreen() { QImage idle_call(QString(SOWATCH_RESOURCES_DIR "/metawatch/graphics/idle_call.bmp")); - QImage idle_sms(QString(SOWATCH_RESOURCES_DIR "/metawatch/graphics/idle_sms.bmp")); - QImage idle_mail(QString(SOWATCH_RESOURCES_DIR "/metawatch/graphics/idle_gmail.bmp")); + QImage idle_msg(QString(SOWATCH_RESOURCES_DIR "/metawatch/graphics/idle_msg.bmp")); + QImage idle_mail(QString(SOWATCH_RESOURCES_DIR "/metawatch/graphics/idle_mail.bmp")); QPainter p; _paintMode = IdleMode; @@ -158,7 +158,7 @@ void MetaWatchDigital::renderIdleScreen() p.drawLine(1, systemAreaHeight * 2 + 4, screenWidth - 2, systemAreaHeight * 2 + 4); p.drawImage((32 * 0) + 4, systemAreaHeight * 2 + 7, idle_call); - p.drawImage((32 * 1) + 4, systemAreaHeight * 2 + 7, idle_sms); + p.drawImage((32 * 1) + 4, systemAreaHeight * 2 + 7, idle_msg); p.drawImage((32 * 2) + 4, systemAreaHeight * 2 + 7, idle_mail); p.end(); diff --git a/metawatch/res/graphics/idle_gmail.bmp b/metawatch/res/graphics/idle_gmail.bmp deleted file mode 100644 index fd129b0..0000000 Binary files a/metawatch/res/graphics/idle_gmail.bmp and /dev/null differ diff --git a/metawatch/res/graphics/idle_mail.bmp b/metawatch/res/graphics/idle_mail.bmp new file mode 100644 index 0000000..253b5bf Binary files /dev/null and b/metawatch/res/graphics/idle_mail.bmp differ diff --git a/metawatch/res/graphics/idle_msg.bmp b/metawatch/res/graphics/idle_msg.bmp new file mode 100644 index 0000000..5eada49 Binary files /dev/null and b/metawatch/res/graphics/idle_msg.bmp differ diff --git a/metawatch/res/graphics/idle_sms.bmp b/metawatch/res/graphics/idle_sms.bmp deleted file mode 100644 index 095ca62..0000000 Binary files a/metawatch/res/graphics/idle_sms.bmp and /dev/null differ 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 +#include #include #include @@ -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); -- cgit v1.2.3