mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Allow html10n to handle import paths relative to the importing file
This commit is contained in:
parent
9d459687af
commit
00d7ebc646
1 changed files with 15 additions and 6 deletions
|
@ -92,7 +92,7 @@ window.html10n = (function(window, document, undefined) {
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
if (this.cache[href]) {
|
if (this.cache[href]) {
|
||||||
this.parse(lang, this.cache[href], cb)
|
this.parse(lang, href, this.cache[href], cb)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ window.html10n = (function(window, document, undefined) {
|
||||||
var data = JSON.parse(xhr.responseText)
|
var data = JSON.parse(xhr.responseText)
|
||||||
that.cache[href] = data
|
that.cache[href] = data
|
||||||
// Pass on the contents for parsing
|
// Pass on the contents for parsing
|
||||||
that.parse(lang, data, cb)
|
that.parse(lang, href, data, cb)
|
||||||
} else {
|
} else {
|
||||||
cb(new Error('Failed to load '+href))
|
cb(new Error('Failed to load '+href))
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ window.html10n = (function(window, document, undefined) {
|
||||||
xhr.send(null);
|
xhr.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader.prototype.parse = function(lang, data, cb) {
|
Loader.prototype.parse = function(lang, currHref, data, cb) {
|
||||||
if ('object' != typeof data) {
|
if ('object' != typeof data) {
|
||||||
cb(new Error('A file couldn\'t be parsed as json.'))
|
cb(new Error('A file couldn\'t be parsed as json.'))
|
||||||
return
|
return
|
||||||
|
@ -130,7 +130,16 @@ window.html10n = (function(window, document, undefined) {
|
||||||
|
|
||||||
if ('string' == typeof data[lang]) {
|
if ('string' == typeof data[lang]) {
|
||||||
// Import rule
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue