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

Delta Between Two Patch Sets: i18n.js

Issue 29333819: Issue 2375 - Implement "Blocking lists" section in new options page (Closed)
Left Patch Set: Created Jan. 26, 2016, 6:33 p.m.
Right Patch Set: Fixed the progress indicator and small fixes Created Feb. 4, 2016, 5:43 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
LEFTRIGHT
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 *
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 var className = node.className; 78 var className = node.className;
79 if (className instanceof SVGAnimatedString) 79 if (className instanceof SVGAnimatedString)
80 className = className.animVal; 80 className = className.animVal;
81 var stringName = className.split(/\s/)[0].substring(5); 81 var stringName = className.split(/\s/)[0].substring(5);
82 82
83 ext.i18n.setElementText(node, stringName, arguments); 83 ext.i18n.setElementText(node, stringName, arguments);
84 } 84 }
85 } 85 }
86 addI18nStringsToElements(document); 86 addI18nStringsToElements(document);
87 // Content of Template is not rendered on tuntime so we need to add 87 // Content of Template is not rendered on runtime so we need to add
Thomas Greiner 2016/01/27 17:16:59 Typo: Replace "tuntime" with "runtime".
saroyanm 2016/01/28 17:00:13 Done.
88 // translation strings for each Template documentFragment content individually 88 // translation strings for each Template documentFragment content individually
89 var templates = document.querySelectorAll("template"); 89 var templates = document.querySelectorAll("template");
90 for (var i = 0; i < templates.length; i++) 90 for (var i = 0; i < templates.length; i++)
91 addI18nStringsToElements(templates[i].content); 91 addI18nStringsToElements(templates[i].content);
92 } 92 }
93 93
94 // Provides a more readable string of the current date and time 94 // Provides a more readable string of the current date and time
95 function i18n_timeDateStrings(when) 95 function i18n_timeDateStrings(when)
96 { 96 {
97 var d = new Date(when); 97 var d = new Date(when);
98 var timeString = d.toLocaleTimeString(); 98 var timeString = d.toLocaleTimeString();
99 99
100 var now = new Date(); 100 var now = new Date();
101 if (d.toDateString() == now.toDateString()) 101 if (d.toDateString() == now.toDateString())
102 return [timeString]; 102 return [timeString];
103 else 103 else
104 return [timeString, d.toLocaleDateString()]; 104 return [timeString, d.toLocaleDateString()];
105 } 105 }
106 106
107 // Formats date string to ["yyyy-mm-dd", "mm:ss"] format 107 // Formats date string to ["YYYY-MM-DD", "mm:ss"] format
108 function i18n_formatDateTime(when) 108 function i18n_formatDateTime(when)
109 { 109 {
110 var date = new Date(when); 110 var date = new Date(when);
111 var dateParts = [date.getFullYear(), date.getMonth()+1, date.getDate(), 111 var dateParts = [date.getFullYear(), date.getMonth() + 1, date.getDate(),
Thomas Greiner 2016/01/27 17:16:58 Detail: Missing whitespace around `+` operator.
saroyanm 2016/01/28 17:00:12 Done.
112 date.getHours(), date.getMinutes()]; 112 date.getHours(), date.getMinutes()];
113
114 for (var i = 0; i < dateParts.length; i++)
115 if (dateParts[i] < 10)
116 dateParts[i] = "0" + dateParts[i];
Thomas Greiner 2016/01/27 17:16:59 Detail: This is basically what `Array.prototype.ma
saroyanm 2016/01/28 17:00:13 God bless development without IE8! Done.
117 113
118 return [dateParts.splice(0, 3).join("-"), dateParts.splice(0, 2).join(":")]; 114 var dateParts = dateParts.map(function(datePart)
Thomas Greiner 2016/01/27 17:16:58 The first `splice()` removes elements from `datePa
saroyanm 2016/01/28 17:00:13 Done.
115 {
116 return datePart < 10 ? "0" + datePart : datePart;
117 });
118
119 return [dateParts.splice(0, 3).join("-"), dateParts.join(":")];
119 } 120 }
120 121
121 // Fill in the strings as soon as possible 122 // Fill in the strings as soon as possible
122 window.addEventListener("DOMContentLoaded", loadI18nStrings, true); 123 window.addEventListener("DOMContentLoaded", loadI18nStrings, true);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld