Add kick-off code for client-side l10n
This commit is contained in:
parent
edacb3e2ca
commit
25be9b8c93
2 changed files with 21 additions and 0 deletions
|
@ -804,6 +804,14 @@ window.html10n = (function(window, document, undefined) {
|
|||
cb(null, build)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
|
13
src/static/js/l10n.js
Normal file
13
src/static/js/l10n.js
Normal 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)
|
Loading…
Reference in a new issue