| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 var i18n; | 18 var i18n; |
| 19 if (typeof chrome != "undefined") | 19 if (typeof chrome != "undefined") |
| 20 { | 20 { |
| 21 i18n = chrome.i18n; | 21 i18n = chrome.i18n; |
| 22 } | 22 } |
| 23 else | 23 else |
| 24 { | 24 { |
| 25 // Using Firefox' approach on i18n instead | 25 // Using Firefox' approach on i18n instead |
| 26 | 26 |
| 27 // Randomize URI to work around bug 719376 | 27 // Randomize URI to work around bug 719376 |
| 28 var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, ''); | 28 var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, ''); |
| 29 var stringBundle = Services.strings.createBundle("/locale/" + pageName + | 29 var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/ " + pageName + |
| 30 ".properties?" + Math.random()); | 30 ".properties?" + Math.random()); |
| 31 | 31 |
| 32 function getI18nMessage(key) | 32 function getI18nMessage(key) |
| 33 { | 33 { |
| 34 return { | 34 return { |
| 35 "message": stringBundle.GetStringFromName(key) | 35 "message": stringBundle.GetStringFromName(key) |
| 36 }; | 36 }; |
| 37 } | 37 } |
| 38 | 38 |
| 39 i18n = (function() | 39 i18n = (function() |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 67 | 67 |
| 68 return { | 68 return { |
| 69 getMessage: function(key, args) | 69 getMessage: function(key, args) |
| 70 { | 70 { |
| 71 try{ | 71 try{ |
| 72 var message = getI18nMessage(key); | 72 var message = getI18nMessage(key); |
| 73 return getText(message, args); | 73 return getText(message, args); |
| 74 } | 74 } |
| 75 catch(e) | 75 catch(e) |
| 76 { | 76 { |
| 77 Cu.reportError(e); | |
| 77 return "Missing translation: " + key; | 78 return "Missing translation: " + key; |
|
Wladimir Palant
2013/05/27 14:10:37
Cu.reportError(e) before returning please - a miss
Thomas Greiner
2013/05/27 16:39:16
Done.
| |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 }; | 81 }; |
| 81 })(); | 82 })(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 // Loads and inserts i18n strings into matching elements. Any inner HTML already in the | 85 // Loads and inserts i18n strings into matching elements. Any inner HTML already in the |
| 85 // element is parsed as JSON and used as parameters to substitute into placehold ers in the | 86 // element is parsed as JSON and used as parameters to substitute into placehold ers in the |
| 86 // i18n message. | 87 // i18n message. |
| 87 function loadI18nStrings() | 88 function loadI18nStrings() |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 110 | 111 |
| 111 var now = new Date(); | 112 var now = new Date(); |
| 112 if (d.toDateString() == now.toDateString()) | 113 if (d.toDateString() == now.toDateString()) |
| 113 return [timeString]; | 114 return [timeString]; |
| 114 else | 115 else |
| 115 return [timeString, d.toLocaleDateString()]; | 116 return [timeString, d.toLocaleDateString()]; |
| 116 } | 117 } |
| 117 | 118 |
| 118 // Fill in the strings as soon as possible | 119 // Fill in the strings as soon as possible |
| 119 window.addEventListener("DOMContentLoaded", loadI18nStrings, true); | 120 window.addEventListener("DOMContentLoaded", loadI18nStrings, true); |
| LEFT | RIGHT |