Fix html10n and the locale resource <link>s

This commit is contained in:
Marcel Klehr 2012-12-17 18:18:20 +01:00
parent 2b860986e8
commit 67c893aaca
4 changed files with 15 additions and 9 deletions

View file

@ -54,9 +54,9 @@ window.html10n = (function(window, document, undefined) {
*/
MicroEvent.mixin = function(destObject){
var props = ['bind', 'unbind', 'trigger'];
if(!destObject.prototype) destObject.prototype = {};
if(!destObject) return;
for(var i = 0; i < props.length; i ++){
destObject.prototype[props[i]] = MicroEvent.prototype[props[i]];
destObject[props[i]] = MicroEvent.prototype[props[i]];
}
}
@ -148,8 +148,8 @@ window.html10n = (function(window, document, undefined) {
/**
* The html10n object
*/
var html10n =
{ language: null
var html10n =
{ language : null
}
MicroEvent.mixin(html10n)
@ -819,6 +819,7 @@ window.html10n = (function(window, document, undefined) {
html10n.index = function () {
// Find all <link>s
var links = document.getElementsByTagName('link')
, resources = []
for (var i=0, n=links.length; i < n; i++) {
if (links[i].type != 'application/l10n+json')
continue;
@ -829,12 +830,17 @@ window.html10n = (function(window, document, undefined) {
}
if (document.addEventListener) // modern browsers and IE9+
document.addEventListener('DOMContentLoaded', html10n.index, false)
document.addEventListener('DOMContentLoaded', function() {
html10n.index()
}, false)
else if (window.attachEvent)
document.attachEvent('onload', html10n.index, false)
document.attachEvent('onload', function() {
html10n.index()
}, false)
// gettext-like shortcut
if (window._ === undefined)
var _ = html10n.get;
return html10n
})(window, document)

View file

@ -33,7 +33,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="shortcut icon" href="<%=settings.favicon%>">
<link rel="localizations" type="application/l10n+json" href="../locales.ini" />
<link rel="localizations" type="application/l10n+json" href="../locales.json" />
<script type="text/javascript" src="../static/js/html10n.js"></script>
<script type="text/javascript" src="../static/js/l10n.js"></script>

View file

@ -34,7 +34,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="shortcut icon" href="<%=settings.faviconPad%>">
<link rel="localizations" type="application/l10n+json" href="../locales.ini" />
<link rel="localizations" type="application/l10n+json" href="../locales.json" />
<script type="text/javascript" src="../static/js/html10n.js"></script>
<script type="text/javascript" src="../static/js/l10n.js"></script>

View file

@ -33,7 +33,7 @@
<meta name="robots" content="noindex, nofollow">
<link rel="shortcut icon" href="<%=settings.faviconTimeslider%>">
<link rel="localizations" type="application/l10n+json" href="../../locales.ini" />
<link rel="localizations" type="application/l10n+json" href="../../locales.json" />
<script type="text/javascript" src="../../static/js/html10n.js"></script>
<script type="text/javascript" src="../../static/js/l10n.js"></script>