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

Unified Diff: lib/utils.js

Issue 29338190: Issue 3697 - Fall back to i18n.getUILanguage if @ui_locale isn't supported (Closed)
Patch Set: Add try-catch blocks. Address nits. Created May 29, 2016, 12:23 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 | « lib/notificationHelper.js ('k') | safari/ext/common.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/utils.js
diff --git a/lib/utils.js b/lib/utils.js
index 33e2fca6de0e6311cdff38eb84e402679c97db34..5b8746aa389d014cf3028ef7696e64087e39f72d 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -44,10 +44,37 @@ var Utils = exports.Utils = {
},
get appLocale()
{
- var locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-");
+ var locale;
+ try
+ {
+ locale = ext.i18n.getMessage("@@ui_locale");
+ }
+ catch (exception)
+ {
+ // Edge does not yet (?) support @@ui_locale, throwing an exception here.
+ }
+ if (!locale)
+ locale = ext.i18n.getUILanguage();
Sebastian Noack 2017/08/23 12:26:44 It seems we can use chrome.i18n.getUILanguage() re
+ locale = locale.replace(/_/g, "-");
Object.defineProperty(this, "appLocale", {value: locale, enumerable: true});
return this.appLocale;
},
+ get readingDirection()
+ {
+ var direction;
+ try
+ {
+ direction = ext.i18n.getMessage("@@bidi_dir");
+ }
+ catch (exception)
+ {
+ // Edge does not yet (?) support @@bidi_dir, throwing an exception here.
+ }
+ if (!direction)
+ direction = /^(ar|fa|he|ug|ur)(_|$)/.test(this.appLocale) ? "rtl" : "ltr";
+ Object.defineProperty(this, "readingDirection", {value: direction, enumerable: true});
+ return this.readingDirection;
+ },
generateChecksum: function(lines)
{
// We cannot calculate MD5 checksums yet :-(
« no previous file with comments | « lib/notificationHelper.js ('k') | safari/ext/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld