Fix citeproc-js in Firefox 56
Our retrieveLocale() implementation was broken by https://bugzilla.mozilla.org/show_bug.cgi?id=1319111
This commit is contained in:
parent
330054e936
commit
4b3d0054e5
1 changed files with 5 additions and 13 deletions
|
@ -556,21 +556,13 @@ Zotero.Cite.System.prototype = {
|
||||||
* @return {String|Boolean} The locale as a string if it exists, or false if it doesn't
|
* @return {String|Boolean} The locale as a string if it exists, or false if it doesn't
|
||||||
*/
|
*/
|
||||||
"retrieveLocale":function retrieveLocale(lang) {
|
"retrieveLocale":function retrieveLocale(lang) {
|
||||||
var protHandler = Components.classes["@mozilla.org/network/protocol;1?name=chrome"]
|
|
||||||
.createInstance(Components.interfaces.nsIProtocolHandler);
|
|
||||||
try {
|
try {
|
||||||
var channel = protHandler.newChannel(protHandler.newURI("chrome://zotero/content/locale/csl/locales-"+lang+".xml", "UTF-8", null));
|
return Zotero.File.getContentsFromURL(
|
||||||
var rawStream = channel.open();
|
`chrome://zotero/content/locale/csl/locales-${lang}.xml`
|
||||||
} catch(e) {
|
);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var converterStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
|
|
||||||
.createInstance(Components.interfaces.nsIConverterInputStream);
|
|
||||||
converterStream.init(rawStream, "UTF-8", 65535,
|
|
||||||
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
|
|
||||||
var str = {};
|
|
||||||
converterStream.readString(channel.contentLength, str);
|
|
||||||
converterStream.close();
|
|
||||||
return str.value;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue