summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2012-12-16 18:52:39 +0100
committerMarcel Klehr <mklehr@gmx.net>2012-12-23 18:16:17 +0100
commit25be9b8c93ce31a88a5c560908c9bfd2708f44a5 (patch)
treeb8b875157e894d6e288670be83b8bf60f69cc361 /src
parentedacb3e2ca7a5b1307ac572cb6af3d418286b047 (diff)
downloadetherpad-lite-25be9b8c93ce31a88a5c560908c9bfd2708f44a5.zip
Add kick-off code for client-side l10n
Diffstat (limited to 'src')
-rw-r--r--src/static/js/html10n.js8
-rw-r--r--src/static/js/l10n.js13
2 files changed, 21 insertions, 0 deletions
diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js
index a38f76d7..9c85cd2f 100644
--- a/src/static/js/html10n.js
+++ b/src/static/js/html10n.js
@@ -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
diff --git a/src/static/js/l10n.js b/src/static/js/l10n.js
new file mode 100644
index 00000000..0bd060fe
--- /dev/null
+++ b/src/static/js/l10n.js
@@ -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) \ No newline at end of file