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

Side by Side Diff: lib/utils.js

Issue 29338190: Issue 3697 - Fall back to i18n.getUILanguage if @ui_locale isn't supported (Closed)
Patch Set: Created March 14, 2016, 7:54 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/notificationHelper.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 26 matching lines...) Expand all
37 }; 37 };
38 document.addEventListener("DOMContentLoaded", onDOMContentLoaded); 38 document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
39 } 39 }
40 else 40 else
41 { 41 {
42 setTimeout(callback, 0); 42 setTimeout(callback, 0);
43 } 43 }
44 }, 44 },
45 get appLocale() 45 get appLocale()
46 { 46 {
47 var locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); 47 var locale = ext.i18n.getMessage("@@ui_locale");
48 if (locale === "") {
Sebastian Noack 2016/03/14 09:03:06 Nit: We always use == (instead ===) where possible
49 locale = ext.i18n.getUILanguage();
50 }
51 locale = locale.replace(/_/g, "-");
48 Object.defineProperty(this, "appLocale", {value: locale, enumerable: true}); 52 Object.defineProperty(this, "appLocale", {value: locale, enumerable: true});
49 return this.appLocale; 53 return this.appLocale;
50 }, 54 },
55 get readingDirection()
56 {
57 var direction;
58 if ("chromeRegistry" in this) {
59 direction = this.chromeRegistry.isLocaleRTL("adblockplus") ? "rtl" : "lt r";
Sebastian Noack 2016/03/14 09:03:07 This code path is specific to Adblock Plus for Fir
60 }
61 else {
62 var direction = ext.i18n.getMessage("@bidi_dir");
63 if (direction === "") {
64 direction = /^(ar|fa|he|ug|ur)(_|$)/.test(appLocale) ? "rtl" : "ltr" ;
Sebastian Noack 2016/03/14 09:03:07 This logic is redundant with code in safari/ext/co
65 }
66 }
67 Object.defineProperty(this, "readingDirection", {value: direction, enumera ble: true});
68 return this.readingDirection;
69 },
51 generateChecksum: function(lines) 70 generateChecksum: function(lines)
52 { 71 {
53 // We cannot calculate MD5 checksums yet :-( 72 // We cannot calculate MD5 checksums yet :-(
54 return null; 73 return null;
55 }, 74 },
56 makeURI: function(url) 75 makeURI: function(url)
57 { 76 {
58 return Services.io.newURI(url); 77 return Services.io.newURI(url);
59 }, 78 },
60 79
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 133 {
115 var Prefs = require("prefs").Prefs; 134 var Prefs = require("prefs").Prefs;
116 var docLink = Prefs.documentation_link; 135 var docLink = Prefs.documentation_link;
117 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale ); 136 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale );
118 }, 137 },
119 138
120 yield: function() 139 yield: function()
121 { 140 {
122 } 141 }
123 }; 142 };
OLDNEW
« no previous file with comments | « lib/notificationHelper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld