oleid / gnome-shell-teatime

MIT License
37 stars 24 forks source link

TeaTime breaks gnome shell localization #37

Closed jspitz closed 6 years ago

jspitz commented 7 years ago

If the TeaTime extension is installed, parts of the gnome shell calendar are not localized. The date order for instance is wrong, and the weather forecast contains a mix of localized and non-localized strings. See screenshots below for the problem.

I have narrowed down the problem to line 25 of utils.js: Gettext.textdomain(domain); If this is commented out, the problem disappears (but of course at the cost of an un-localized tea timer).

The following screenshot shows the correct German localization (the offending line commented out):

shell-correct

The one below displays the wrong localization TeaTime causes (check out the date format and the weather forecast):

shell-wrong

blackjackshellac commented 7 years ago

have you tried making "domain" local in scope?

diff --git a/src/utils.js b/src/utils.js
index e18f504..12acfd2 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -20,7 +20,7 @@ const TEATIME_ALARM_SOUND_KEY = 'alarm-sound-file';
 function initTranslations(domain) {
     let extension = ExtensionUtils.getCurrentExtension();

-    domain = domain || extension.metadata['gettext-domain'];
+    let domain = domain || extension.metadata['gettext-domain'];

     Gettext.textdomain(domain);
     // check if this extension was built with "make zip-file", and thus

Note that the call to Utils.initTranslations() here doesn't set the domain value.

blackjackshellac commented 7 years ago

Probably shouldn't change the parameter though, JS is complaining about that,

Jun 06 08:45:18 woot.home gnome-shell[3437]: JS WARNING: [/home/steeve/.local/share/gnome-shell/extensions/TeaTime@oleid.mescharet.de/utils.js 23]: variable domain redeclares argum

diff --git a/src/utils.js b/src/utils.js
index e18f504..6a3f2b0 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -17,10 +17,10 @@ const TEATIME_GRAPHICAL_COUNTDOWN_KEY = 'graphical-countdown';
 const TEATIME_USE_ALARM_SOUND_KEY = 'use-alarm-sound';
 const TEATIME_ALARM_SOUND_KEY = 'alarm-sound-file';

-function initTranslations(domain) {
+function initTranslations(_domain) {
     let extension = ExtensionUtils.getCurrentExtension();

-    domain = domain || extension.metadata['gettext-domain'];
+    let domain = _domain || extension.metadata['gettext-domain'];

     Gettext.textdomain(domain);
     // check if this extension was built with "make zip-file", and thus
jspitz commented 7 years ago

have you tried making "domain" local in scope?

Tried that now, did not help.

lazarevdmitriy commented 7 years ago

TeaTime_locale_ru.zip

Russian localization for TeaTime.

oleid commented 6 years ago

I find the problem somewhat opaque. What surprises me most is that this page recommends calling Gettext.textdomain (domain), but the initTranslations function from convenience.js, which is usually copy&pasted to most extensions, doesn't. But oviously, when not setting the domain, no translations are found :/

jspitz commented 6 years ago

I have found a solution, though with a hardcoded domain.

jspitz commented 6 years ago

@oleid did you see my patch (#40)?

jspitz commented 6 years ago

This is fixed with v. 26.