OLD | NEW |
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 |
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 "use strict"; | 18 "use strict"; |
19 | 19 |
20 // Getting UI locale cannot be done synchronously on Firefox, | 20 // Getting UI locale cannot be done synchronously on Firefox, |
21 // requires messaging the background page. For Chrome and Safari, | 21 // requires messaging the background page. For Chrome and Safari, |
22 // we could get the UI locale here, but would need to duplicate | 22 // we could get the UI locale here, but would need to duplicate |
23 // the logic implemented in Utils.appLocale. | 23 // the logic implemented in Utils.appLocale. |
24 chrome.runtime.sendMessage( | 24 browser.runtime.sendMessage( |
25 { | 25 { |
26 type: "app.get", | 26 type: "app.get", |
27 what: "localeInfo" | 27 what: "localeInfo" |
28 }, | 28 }, |
29 (localeInfo) => | 29 (localeInfo) => |
30 { | 30 { |
31 document.documentElement.lang = localeInfo.locale; | 31 document.documentElement.lang = localeInfo.locale; |
32 document.documentElement.dir = localeInfo.bidiDir; | 32 document.documentElement.dir = localeInfo.bidiDir; |
33 } | 33 } |
34 ); | 34 ); |
(...skipping 16 matching lines...) Expand all Loading... |
51 currentElement.appendChild(e); | 51 currentElement.appendChild(e); |
52 | 52 |
53 processString(match[4], currentElement); | 53 processString(match[4], currentElement); |
54 } | 54 } |
55 else | 55 else |
56 currentElement.appendChild(document.createTextNode(str)); | 56 currentElement.appendChild(document.createTextNode(str)); |
57 } | 57 } |
58 | 58 |
59 while (element.lastChild) | 59 while (element.lastChild) |
60 element.removeChild(element.lastChild); | 60 element.removeChild(element.lastChild); |
61 processString(chrome.i18n.getMessage(stringName, args), element); | 61 processString(browser.i18n.getMessage(stringName, args), element); |
62 } | 62 } |
63 }; | 63 }; |
64 | 64 |
65 // Loads i18n strings | 65 // Loads i18n strings |
66 function loadI18nStrings() | 66 function loadI18nStrings() |
67 { | 67 { |
68 function addI18nStringsToElements(containerElement) | 68 function addI18nStringsToElements(containerElement) |
69 { | 69 { |
70 let elements = containerElement.querySelectorAll("[class^='i18n_']"); | 70 let elements = containerElement.querySelectorAll("[class^='i18n_']"); |
71 for (let node of elements) | 71 for (let node of elements) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 dateParts = dateParts.map( | 112 dateParts = dateParts.map( |
113 (datePart) => datePart < 10 ? "0" + datePart : datePart | 113 (datePart) => datePart < 10 ? "0" + datePart : datePart |
114 ); | 114 ); |
115 | 115 |
116 return [dateParts.splice(0, 3).join("-"), dateParts.join(":")]; | 116 return [dateParts.splice(0, 3).join("-"), dateParts.join(":")]; |
117 } | 117 } |
118 | 118 |
119 // Fill in the strings as soon as possible | 119 // Fill in the strings as soon as possible |
120 window.addEventListener("DOMContentLoaded", loadI18nStrings, true); | 120 window.addEventListener("DOMContentLoaded", loadI18nStrings, true); |
OLD | NEW |