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: Rebase and just use i18n.getUILanguage() Created Aug. 25, 2017, 11:22 p.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 25 matching lines...) Expand all
36 }; 36 };
37 document.addEventListener("DOMContentLoaded", onDOMContentLoaded); 37 document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
38 } 38 }
39 else 39 else
40 { 40 {
41 setTimeout(callback, 0); 41 setTimeout(callback, 0);
42 } 42 }
43 }, 43 },
44 get appLocale() 44 get appLocale()
45 { 45 {
46 let locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); 46 let locale = ext.i18n.getUILanguage().replace(/_/g, "-");
47 Object.defineProperty(this, "appLocale", {value: locale, enumerable: true}); 47 Object.defineProperty(this, "appLocale", {value: locale, enumerable: true});
48 return this.appLocale; 48 return this.appLocale;
49 }, 49 },
50 get readingDirection()
51 {
52 let direction = ext.i18n.getMessage("@@bidi_dir");
53 if (!direction)
Sebastian Noack 2017/08/26 07:16:47 We probably should add a comment that this fallbac
54 direction = /^(ar|fa|he|ug|ur)(_|$)/.test(this.appLocale) ? "rtl" : "ltr";
55 Object.defineProperty(
56 this,
57 "readingDirection",
58 {value: direction, enumerable: true});
59 return this.readingDirection;
60 },
50 generateChecksum(lines) 61 generateChecksum(lines)
51 { 62 {
52 // We cannot calculate MD5 checksums yet :-( 63 // We cannot calculate MD5 checksums yet :-(
53 return null; 64 return null;
54 }, 65 },
55 checkLocalePrefixMatch(prefixes) 66 checkLocalePrefixMatch(prefixes)
56 { 67 {
57 if (!prefixes) 68 if (!prefixes)
58 return null; 69 return null;
59 70
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 { 121 {
111 let docLink = require("prefs").Prefs.documentation_link; 122 let docLink = require("prefs").Prefs.documentation_link;
112 return docLink.replace(/%LINK%/g, linkID) 123 return docLink.replace(/%LINK%/g, linkID)
113 .replace(/%LANG%/g, Utils.appLocale); 124 .replace(/%LANG%/g, Utils.appLocale);
114 }, 125 },
115 126
116 yield() 127 yield()
117 { 128 {
118 } 129 }
119 }; 130 };
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