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

Delta Between Two Patch Sets: i18n.js

Issue 6432313504169984: Issue 1663 - Various Firefox-related changes of the first-run page (Closed)
Left Patch Set: Created Jan. 6, 2015, 10:19 p.m.
Right Patch Set: Addressed comments Created Jan. 7, 2015, 4:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « firstRun.js ('k') | messageResponder.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 // This variable should no longer be necessary once options.js in Chrome 18 // This variable should no longer be necessary once options.js in Chrome
19 // accesses ext.i18n directly. 19 // accesses ext.i18n directly.
20 var i18n = ext.i18n; 20 var i18n = ext.i18n;
21 21
22 if (ext.i18n.noSpecialMessages) 22 if (ext.i18n.getMessage("@@ui_locale"))
23 { 23 {
24 document.documentElement.lang = ext.i18n.getMessage("@@ui_locale").replace(/_/ g, "-");
25 document.documentElement.dir = ext.i18n.getMessage("@@bidi_dir");
26 }
27 else
28 {
29 // Getting UI locale cannot be done synchronously on Firefox, requires
30 // messaging the background page.
24 ext.backgroundPage.sendMessage({ 31 ext.backgroundPage.sendMessage({
25 type: "app.get", 32 type: "app.get",
26 what: "localeInfo" 33 what: "localeInfo"
27 }, function(localeInfo) 34 }, function(localeInfo)
28 { 35 {
29 document.documentElement.lang = localeInfo.locale; 36 document.documentElement.lang = localeInfo.locale;
30 document.documentElement.dir = localeInfo.isRTL ? "rtl" : "ltr"; 37 document.documentElement.dir = localeInfo.isRTL ? "rtl" : "ltr";
31 }); 38 });
32 }
33 else
34 {
35 document.documentElement.lang = ext.i18n.getMessage("@@ui_locale").replace(/_/ g, "-");
36 document.documentElement.dir = ext.i18n.getMessage("@@bidi_dir");
37 } 39 }
38 40
39 // Inserts i18n strings into matching elements. Any inner HTML already in the el ement is 41 // Inserts i18n strings into matching elements. Any inner HTML already in the el ement is
40 // parsed as JSON and used as parameters to substitute into placeholders in the i18n 42 // parsed as JSON and used as parameters to substitute into placeholders in the i18n
41 // message. 43 // message.
42 ext.i18n.setElementText = function(element, stringName, arguments) 44 ext.i18n.setElementText = function(element, stringName, arguments)
43 { 45 {
44 function processString(str, element) 46 function processString(str, element)
45 { 47 {
46 var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(str); 48 var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(str);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 93
92 var now = new Date(); 94 var now = new Date();
93 if (d.toDateString() == now.toDateString()) 95 if (d.toDateString() == now.toDateString())
94 return [timeString]; 96 return [timeString];
95 else 97 else
96 return [timeString, d.toLocaleDateString()]; 98 return [timeString, d.toLocaleDateString()];
97 } 99 }
98 100
99 // Fill in the strings as soon as possible 101 // Fill in the strings as soon as possible
100 window.addEventListener("DOMContentLoaded", loadI18nStrings, true); 102 window.addEventListener("DOMContentLoaded", loadI18nStrings, true);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld