Index: i18n.js |
=================================================================== |
--- a/i18n.js |
+++ b/i18n.js |
@@ -65,21 +65,30 @@ |
// Loads i18n strings |
function loadI18nStrings() |
{ |
- var nodes = document.querySelectorAll("[class^='i18n_']"); |
- for(var i = 0; i < nodes.length; i++) |
+ function addI18nStringsToElements(containerElement) |
{ |
- var node = nodes[i]; |
- var arguments = JSON.parse("[" + node.textContent + "]"); |
- if (arguments.length == 0) |
- arguments = null; |
+ var elements = containerElement.querySelectorAll("[class^='i18n_']"); |
+ for(var i = 0; i < elements.length; i++) |
+ { |
+ var node = elements[i]; |
+ var arguments = JSON.parse("[" + node.textContent + "]"); |
+ if (arguments.length == 0) |
+ arguments = null; |
- var className = node.className; |
- if (className instanceof SVGAnimatedString) |
- className = className.animVal; |
- var stringName = className.split(/\s/)[0].substring(5); |
+ var className = node.className; |
+ if (className instanceof SVGAnimatedString) |
+ className = className.animVal; |
+ var stringName = className.split(/\s/)[0].substring(5); |
- ext.i18n.setElementText(node, stringName, arguments); |
+ ext.i18n.setElementText(node, stringName, arguments); |
+ } |
} |
+ addI18nStringsToElements(document); |
+ // Content of Template is not rendered on tuntime 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.
|
+ // translation strings for each Template documentFragment content individually |
+ var templates = document.querySelectorAll("template"); |
+ for (var i = 0; i < templates.length; i++) |
+ addI18nStringsToElements(templates[i].content); |
} |
// Provides a more readable string of the current date and time |
@@ -95,5 +104,19 @@ |
return [timeString, d.toLocaleDateString()]; |
} |
+// Formats date string to ["yyyy-mm-dd", "mm:ss"] format |
+function i18n_formatDateTime(when) |
+{ |
+ var date = new Date(when); |
+ 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.
|
+ date.getHours(), date.getMinutes()]; |
+ |
+ for (var i = 0; i < dateParts.length; i++) |
+ if (dateParts[i] < 10) |
+ 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.
|
+ |
+ return [dateParts.splice(0, 3).join("-"), dateParts.splice(0, 2).join(":")]; |
Thomas Greiner
2016/01/27 17:16:58
The first `splice()` removes elements from `datePa
saroyanm
2016/01/28 17:00:13
Done.
|
+} |
+ |
// Fill in the strings as soon as possible |
window.addEventListener("DOMContentLoaded", loadI18nStrings, true); |