[Pkg-mozext-commits] [adblock-plus] 24/41: Issue 2067 - Unify logic retrieving the UI locale

David Prévot taffit at moszumanska.debian.org
Wed Mar 18 18:21:38 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit 464825772810cee131a07bd024e24b64d048a851
Author: Sebastian Noack <sebastian at adblockplus.org>
Date:   Sun Mar 1 13:55:10 2015 +0100

    Issue 2067 - Unify logic retrieving the UI locale
---
 i18n.js             | 25 +++++++++++--------------
 messageResponder.js | 11 +++++++----
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/i18n.js b/i18n.js
index 6cf6cb7..9d380b7 100644
--- a/i18n.js
+++ b/i18n.js
@@ -19,24 +19,21 @@
 // accesses ext.i18n directly.
 var i18n = ext.i18n;
 
-if (ext.i18n.getMessage("@@ui_locale"))
-{
-  document.documentElement.lang = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-");
-  document.documentElement.dir = ext.i18n.getMessage("@@bidi_dir");
-}
-else
-{
-  // Getting UI locale cannot be done synchronously on Firefox, requires
-  // messaging the background page.
-  ext.backgroundPage.sendMessage({
+// Getting UI locale cannot be done synchronously on Firefox,
+// requires messaging the background page. For Chrome and Safari,
+// we could get the UI locale here, but would need to duplicate
+// the logic implemented in Utils.appLocale.
+ext.backgroundPage.sendMessage(
+  {
     type: "app.get",
     what: "localeInfo"
-  }, function(localeInfo)
+  },
+  function(localeInfo)
   {
     document.documentElement.lang = localeInfo.locale;
-    document.documentElement.dir = localeInfo.isRTL ? "rtl" : "ltr";
-  });
-}
+    document.documentElement.dir = localeInfo.bidiDir;
+  }
+);
 
 // Inserts i18n strings into matching elements. Any inner HTML already in the element is
 // parsed as JSON and used as parameters to substitute into placeholders in the i18n
diff --git a/messageResponder.js b/messageResponder.js
index cf11a1b..0f5ff0e 100644
--- a/messageResponder.js
+++ b/messageResponder.js
@@ -110,10 +110,13 @@
           callback(Utils.getDocLink(message.link));
         else if (message.what == "localeInfo")
         {
-          callback({
-            locale: Utils.appLocale,
-            isRTL: Utils.chromeRegistry.isLocaleRTL("adblockplus")
-          });
+          var bidiDir;
+          if ("chromeRegistry" in Utils)
+            bidiDir = Utils.chromeRegistry.isLocaleRTL("adblockplus") ? "rtl" : "ltr";
+          else
+            bidiDir = ext.i18n.getMessage("@@bidi_dir");
+
+          callback({locale: Utils.appLocale, bidiDir: bidiDir});
         }
         else
           callback(null);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list