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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 * Localizes the texts of the supplied notification. | 357 * Localizes the texts of the supplied notification. |
358 * @param {Object} notification notification to translate | 358 * @param {Object} notification notification to translate |
359 * @param {string} locale the target locale (optional, defaults to the | 359 * @param {string} locale the target locale (optional, defaults to the |
360 * application locale) | 360 * application locale) |
361 * @return {Object} the translated texts | 361 * @return {Object} the translated texts |
362 */ | 362 */ |
363 getLocalizedTexts(notification, locale) | 363 getLocalizedTexts(notification, locale) |
364 { | 364 { |
365 locale = locale || Utils.appLocale; | 365 locale = locale || Utils.appLocale; |
366 let textKeys = ["title", "message"]; | 366 let textKeys = ["title", "message"]; |
367 let localizedTexts = []; | 367 let localizedTexts = {}; |
368 for (let key of textKeys) | 368 for (let key of textKeys) |
369 { | 369 { |
370 if (key in notification) | 370 if (key in notification) |
371 { | 371 { |
372 if (typeof notification[key] == "string") | 372 if (typeof notification[key] == "string") |
373 localizedTexts[key] = notification[key]; | 373 localizedTexts[key] = notification[key]; |
374 else | 374 else |
375 localizedTexts[key] = localize(notification[key], locale); | 375 localizedTexts[key] = localize(notification[key], locale); |
376 } | 376 } |
377 } | 377 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 else if (index != -1 && forceValue !== true) | 466 else if (index != -1 && forceValue !== true) |
467 categories.splice(index, 1); | 467 categories.splice(index, 1); |
468 | 468 |
469 // HACK: JSON values aren't saved unless they are assigned a | 469 // HACK: JSON values aren't saved unless they are assigned a |
470 // different object. | 470 // different object. |
471 Prefs.notifications_ignoredcategories = | 471 Prefs.notifications_ignoredcategories = |
472 JSON.parse(JSON.stringify(categories)); | 472 JSON.parse(JSON.stringify(categories)); |
473 } | 473 } |
474 }; | 474 }; |
475 Notification.init(); | 475 Notification.init(); |
OLD | NEW |