Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: i18n.js

Issue 6289768170127360: Issue 2067 - Unify logic retrieving the UI locale (Closed)
Patch Set: Fixed: There is no ext.i18n in the background page on Firefox Created March 2, 2015, 11:55 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: i18n.js
===================================================================
--- 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
« no previous file with comments | « no previous file | messageResponder.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld