diff options
-rw-r--r-- | README.rst | 4 | ||||
-rw-r--r-- | src/dbus/server/main.cpp | 9 | ||||
-rw-r--r-- | src/dbus/server/notification-backend-libnotify.cpp | 4 | ||||
-rwxr-xr-x | test/runtests.py | 12 | ||||
-rwxr-xr-x | test/test-dbus.py | 63 |
5 files changed, 70 insertions, 22 deletions
@@ -1100,6 +1100,10 @@ SYNCEVOLUTION_LIBEXEC_DIR Overrides the path where additional helper executables are found, normally `/usr/libexec`. +SYNCEVOLUTION_LOCALE_DIR + Overrides the path to directories with the different translations, + normally `/usr/share/locale`. + SYNCEVOLUTION_TEMPLATE_DIR Overrides the default path to template files, normally `/usr/share/syncevolution/templates`. diff --git a/src/dbus/server/main.cpp b/src/dbus/server/main.cpp index 6fceb013..ae071490 100644 --- a/src/dbus/server/main.cpp +++ b/src/dbus/server/main.cpp @@ -22,6 +22,8 @@ #endif #include <iostream> +#include <locale.h> +#include <glib/gi18n.h> #include "server.h" #include "restart.h" @@ -70,6 +72,13 @@ int main(int argc, char **argv, char **envp) boost::shared_ptr<Restart> restart; restart.reset(new Restart(argv, envp)); + // Internationalization for auto sync messages. + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, + getEnv("SYNCEVOLUTION_LOCALE_DIR", SYNCEVOLUTION_LOCALEDIR)); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + int duration = 600; int opt = 1; while(opt < argc) { diff --git a/src/dbus/server/notification-backend-libnotify.cpp b/src/dbus/server/notification-backend-libnotify.cpp index 2359083b..e11dc59b 100644 --- a/src/dbus/server/notification-backend-libnotify.cpp +++ b/src/dbus/server/notification-backend-libnotify.cpp @@ -96,10 +96,6 @@ void NotificationBackendLibnotify::notifyAction( bool NotificationBackendLibnotify::init() { - bindtextdomain (GETTEXT_PACKAGE, SYNCEVOLUTION_LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - #ifdef NOTIFY_COMPATIBILITY void *dlhandle = NULL; int i; diff --git a/test/runtests.py b/test/runtests.py index b8d8e904..e1a86fb9 100755 --- a/test/runtests.py +++ b/test/runtests.py @@ -638,6 +638,16 @@ class SyncEvolutionTest(Action): "SYNCEVOLUTION_BACKEND_DIR=%s " \ % ( datadir, templatedir, confdir, backenddir ) + # Translations have no fallback, they must be installed. Leave unset + # if not found. + localedir = os.path.join(self.build.installdir, "usr/share/locale") + print localedir + if os.access(localedir, os.F_OK): + installenv = installenv + \ + ("SYNCEVOLUTION_LOCALE_DIR=%s " % localedir) + else: + print 'locale dir not found' + cmd = "%s %s %s %s %s ./syncevolution" % (self.testenv, installenv, self.runner, context.setupcmd, self.name) context.runCommand(cmd) @@ -647,7 +657,7 @@ class SyncEvolutionTest(Action): "CLIENT_TEST_SOURCES=%(sources)s " \ "SYNC_EVOLUTION_EVO_CALENDAR_DELAY=1 " \ "CLIENT_TEST_ALARM=%(alarm)d " \ - "%(env)s %(installenv)s" \ + "%(env)s %(installenv)s " \ "CLIENT_TEST_LOG=%(log)s " \ "CLIENT_TEST_EVOLUTION_PREFIX=%(evoprefix)s " \ "%(runner)s " \ diff --git a/test/test-dbus.py b/test/test-dbus.py index 7195ffa4..f9812bcb 100755 --- a/test/test-dbus.py +++ b/test/test-dbus.py @@ -2679,18 +2679,35 @@ class TestSessionAPIsDummy(DBusUtil, unittest.TestCase): self.runTestDBusCheck = checkDBusLog @timeout(60) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncNetworkFailure(self): """TestSessionAPIsDummy.testAutoSyncNetworkFailure - test that auto-sync is triggered, fails due to (temporary?!) network error here""" self.doAutoSyncNetworkFailure() @timeout(60) - @property("ENV", "DBUS_TEST_CONNMAN=session DBUS_TEST_NETWORK_MANAGER=session") + @property("ENV", "DBUS_TEST_CONNMAN=session DBUS_TEST_NETWORK_MANAGER=session " + "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncNoNetworkManager(self): """TestSessionAPIsDummy.testAutoSyncNoNetworkManager - test that auto-sync is triggered despite having neither NetworkManager nor Connman, fails due to (temporary?!) network error here""" self.doAutoSyncNetworkFailure() @timeout(60) - def doAutoSyncLocalConfigError(self, notifyLevel): + def doAutoSyncLocalConfigError(self, notifyLevel, + notification= + ' string "SyncEvolution"\n' + ' uint32 0\n' + ' string ""\n' + ' string "Sync problem."\n' + ' string "Sorry, there\'s a problem with your sync that you need to attend to."\n' + ' array [\n' + ' string "view"\n' + ' string "View"\n' + ' string "default"\n' + ' string "Dismiss"\n' + ' ]\n' + ' array [\n' + ' ]\n' + ' int32 -1\n'): self.setupConfig() # enable auto-sync config = copy.deepcopy(self.config) @@ -2743,21 +2760,7 @@ class TestSessionAPIsDummy(DBusUtil, unittest.TestCase): def checkDBusLog(self, content): notifications = GrepNotifications(content) self.assertEqual(notifications, - notifyLevel >= 1 and - [' string "SyncEvolution"\n' - ' uint32 0\n' - ' string ""\n' - ' string "Sync problem."\n' - ' string "Sorry, there\'s a problem with your sync that you need to attend to."\n' - ' array [\n' - ' string "view"\n' - ' string "View"\n' - ' string "default"\n' - ' string "Dismiss"\n' - ' ]\n' - ' array [\n' - ' ]\n' - ' int32 -1\n'] + notifyLevel >= 1 and [notification] or []) # check that no other session is started at the time of @@ -2791,16 +2794,39 @@ class TestSessionAPIsDummy(DBusUtil, unittest.TestCase): self.runTestDBusCheck = checkDBusLog @timeout(60) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncLocalConfigError(self): """TestSessionAPIsDummy.testAutoSyncLocalConfigError - test that auto-sync is triggered for local sync, fails due to permanent config error here""" self.doAutoSyncLocalConfigError(3) @timeout(60) + @property("ENV", "LC_ALL=de_DE.UTF-8 LANGUAGE=de_DE:de") + def testAutoSyncLocalConfigErrorGerman(self): + """TestSessionAPIsDummy.testAutoSyncLocalConfigErrorGerman - test that auto-sync is triggered for local sync, fails due to permanent config error here""" + self.doAutoSyncLocalConfigError(3, + ' string "SyncEvolution"\n' + ' uint32 0\n' + ' string ""\n' + ' string "Sync-Problem"\n' + ' string "Ein Problem mit der Synchronisation bedarf deiner Aufmerksamkeit."\n' + ' array [\n' + ' string "view"\n' + ' string "Anzeigen"\n' + ' string "default"\n' + ' string "Ignorieren"\n' + ' ]\n' + ' array [\n' + ' ]\n' + ' int32 -1\n') + + @timeout(60) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncLocalConfigErrorEssential(self): """TestSessionAPIsDummy.testAutoSyncLocalConfigErrorEssential - test that auto-sync is triggered for local sync, fails due to permanent config error here, with only the essential error notification""" self.doAutoSyncLocalConfigError(1) @timeout(60) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncLocalConfigErrorQuiet(self): """TestSessionAPIsDummy.testAutoSyncLocalConfigErrorQuiet - test that auto-sync is triggered for local sync, fails due to permanent config error here, with no notification""" self.doAutoSyncLocalConfigError(0) @@ -2922,16 +2948,19 @@ class TestSessionAPIsDummy(DBusUtil, unittest.TestCase): self.runTestDBusCheck = checkDBusLog @timeout(120) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncLocalSuccess(self): """TestSessionAPIsDummy.testAutoSyncLocalSuccess - test that auto-sync is done successfully for local sync between file backends, with notifications""" self.doAutoSyncLocalSuccess(3) @timeout(120) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncLocalSuccessQuiet(self): """TestSessionAPIsDummy.testAutoSyncLocalSuccessQuiet - test that auto-sync is done successfully for local sync between file backends, without notifications""" self.doAutoSyncLocalSuccess(1) @timeout(240) + @property("ENV", "LC_ALL=en_US.UTF-8 LANGUAGE=en_US") def testAutoSyncLocalMultiple(self): """TestSessionAPIsDummy.testAutoSyncLocalMultiple - test that auto-sync is done successfully for local sync between file backends, several times""" self.doAutoSyncLocalSuccess(1, repeat=True) |