diff options
author | Marcel Klehr <mklehr@gmx.net> | 2012-12-23 16:51:14 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2012-12-23 18:17:25 +0100 |
commit | fefbdb6fe1929f4e160d57a33b949e1aa5cb7b83 (patch) | |
tree | 666865670a2698957581a7c53a4150da87977d06 | |
parent | fdf6628cc5b6e6f50f7125939de339aa064f3d44 (diff) | |
download | etherpad-lite-fefbdb6fe1929f4e160d57a33b949e1aa5cb7b83.zip |
Add direction info
-rw-r--r-- | src/static/js/html10n.js | 10 | ||||
-rw-r--r-- | src/static/js/l10n.js | 3 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js index ca17bb0e..dc583967 100644 --- a/src/static/js/html10n.js +++ b/src/static/js/html10n.js @@ -163,6 +163,8 @@ window.html10n = (function(window, document, undefined) { MicroEvent.mixin(html10n) html10n.macros = {} + + html10n.rtl = ["ar","dv","fa","ha","he","ks","ku","ps","ur","yi"] /** * Get rules for plural forms (shared with JetPack), see: @@ -832,6 +834,14 @@ window.html10n = (function(window, document, undefined) { } /** + * Returns the direction of the language returned be html10n#getLanguage + */ + html10n.getDirection = function() { + var langCode = this.language.indexOf('-') == -1? this.language : this.language.substr(0, this.language.indexOf('-')) + return html10n.rtl.indexOf(langCode) == -1? 'ltr' : 'rtl' + } + + /** * Index all <link>s */ html10n.index = function () { diff --git a/src/static/js/l10n.js b/src/static/js/l10n.js index 7556b740..a67a7c1a 100644 --- a/src/static/js/l10n.js +++ b/src/static/js/l10n.js @@ -1,6 +1,6 @@ (function(document) { // Set language for l10n - var language = document.cookie.match(/language=(\w{2,3})(-w+)?/); + var language = document.cookie.match(/language=((\w{2,3})(-w+)?)/); if(language) language = language[1]; html10n.bind('indexed', function() { @@ -9,5 +9,6 @@ html10n.bind('localized', function() { document.documentElement.lang = html10n.getLanguage() + document.documentElement.dir = html10n.getDirection() }) })(document)
\ No newline at end of file |