diff options
author | Marcel Klehr <mklehr@gmx.net> | 2012-12-19 19:39:00 +0100 |
---|---|---|
committer | Marcel Klehr <mklehr@gmx.net> | 2012-12-23 18:16:59 +0100 |
commit | 00d7ebc646e648273131dc0d61ce311de88fc49c (patch) | |
tree | a96fdbf7c74ae596453dc88c7b2adb57a44b79a1 /src/static/js/html10n.js | |
parent | 9d459687afc514944d0c56b9567ffe7b33feb84e (diff) | |
download | etherpad-lite-00d7ebc646e648273131dc0d61ce311de88fc49c.zip |
Allow html10n to handle import paths relative to the importing file
Diffstat (limited to 'src/static/js/html10n.js')
-rw-r--r-- | src/static/js/html10n.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/static/js/html10n.js b/src/static/js/html10n.js index 834e3782..7502856f 100644 --- a/src/static/js/html10n.js +++ b/src/static/js/html10n.js @@ -92,7 +92,7 @@ window.html10n = (function(window, document, undefined) { var that = this if (this.cache[href]) { - this.parse(lang, this.cache[href], cb) + this.parse(lang, href, this.cache[href], cb) return; } @@ -107,7 +107,7 @@ window.html10n = (function(window, document, undefined) { var data = JSON.parse(xhr.responseText) that.cache[href] = data // Pass on the contents for parsing - that.parse(lang, data, cb) + that.parse(lang, href, data, cb) } else { cb(new Error('Failed to load '+href)) } @@ -116,7 +116,7 @@ window.html10n = (function(window, document, undefined) { xhr.send(null); } - Loader.prototype.parse = function(lang, data, cb) { + Loader.prototype.parse = function(lang, currHref, data, cb) { if ('object' != typeof data) { cb(new Error('A file couldn\'t be parsed as json.')) return @@ -130,15 +130,24 @@ window.html10n = (function(window, document, undefined) { if ('string' == typeof data[lang]) { // Import rule - this.fetch(data[lang], lang, cb) + + // absolute path + var importUrl = data[lang] + + // relative path + if(data[lang].indexOf("http") != 0 && data[lang].indexOf("/") != 0) { + importUrl = currHref+"/../"+data[lang] + } + + this.fetch(importUrl, lang, cb) return } - + if ('object' != typeof data[lang]) { cb(new Error('Translations should be specified as JSON objects!')) return } - + this.langs[lang] = data[lang] // TODO: Also store accompanying langs cb() |