Add kick-off code for client-side l10n

pull/1297/head
Marcel Klehr 2012-12-16 18:52:39 +01:00
parent edacb3e2ca
commit 25be9b8c93
2 changed files with 21 additions and 0 deletions

View File

@ -805,6 +805,14 @@ window.html10n = (function(window, document, undefined) {
}) })
} }
/**
* Returns the language that was last applied to the translations hash
* thus overriding most of the formerly applied langs
*/
html10n.getLanguage = function() {
this.language
}
/** /**
* Index all <link>s * Index all <link>s
*/ */

13
src/static/js/l10n.js Normal file
View File

@ -0,0 +1,13 @@
(function(document) {
// Set language for l10n
var language = document.cookie.match(/language=(\w{2})/);
if(language) language = language[1];
html10n.bind('indexed', function() {
html10n.localize([language, navigator.language, navigator.userLanguage, 'en'])
})
html10n.bind('localized', function() {
document.documentElement.lang = html10n.getLanguage()
})
})(document)