Merge pull request #559 from aurimasv/patch-1
Allow dependent styles to override parent style locale
This commit is contained in:
commit
aa005041a8
|
@ -448,6 +448,8 @@ Zotero.Style = function(arg) {
|
||||||
for each(category in Zotero.Utilities.xpath(doc,
|
for each(category in Zotero.Utilities.xpath(doc,
|
||||||
'/csl:style/csl:info[1]/csl:category', Zotero.Styles.ns))
|
'/csl:style/csl:info[1]/csl:category', Zotero.Styles.ns))
|
||||||
if(category.hasAttribute("term"))];
|
if(category.hasAttribute("term"))];
|
||||||
|
this.locale = Zotero.Utilities.xpathText(doc, '/csl:style/@default-locale',
|
||||||
|
Zotero.Styles.ns) || null;
|
||||||
this._class = doc.documentElement.getAttribute("class");
|
this._class = doc.documentElement.getAttribute("class");
|
||||||
this._usesAbbreviation = !!Zotero.Utilities.xpath(doc,
|
this._usesAbbreviation = !!Zotero.Utilities.xpath(doc,
|
||||||
'//csl:text[(@variable="container-title" and @form="short") or (@variable="container-title-short")][1]',
|
'//csl:text[(@variable="container-title" and @form="short") or (@variable="container-title-short")][1]',
|
||||||
|
@ -478,6 +480,7 @@ Zotero.Style.prototype.getCiteProc = function(automaticJournalAbbreviations) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine version of parent style
|
// determine version of parent style
|
||||||
|
var overrideLocale = false; // to force dependent style locale
|
||||||
if(this.source) {
|
if(this.source) {
|
||||||
var parentStyle = Zotero.Styles.get(this.source);
|
var parentStyle = Zotero.Styles.get(this.source);
|
||||||
if(!parentStyle) {
|
if(!parentStyle) {
|
||||||
|
@ -485,6 +488,14 @@ Zotero.Style.prototype.getCiteProc = function(automaticJournalAbbreviations) {
|
||||||
Zotero.Styles.ios.newFileURI(this.file).spec, null));
|
Zotero.Styles.ios.newFileURI(this.file).spec, null));
|
||||||
}
|
}
|
||||||
var version = parentStyle._version;
|
var version = parentStyle._version;
|
||||||
|
|
||||||
|
// citeproc-js will not know anything about the dependent style, including
|
||||||
|
// the default-locale, so we need to force locale if a dependent style
|
||||||
|
// contains one
|
||||||
|
if(this.locale) {
|
||||||
|
overrideLocale = true;
|
||||||
|
locale = this.locale;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
var version = this._version;
|
var version = this._version;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +530,12 @@ Zotero.Style.prototype.getCiteProc = function(automaticJournalAbbreviations) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new Zotero.CiteProc.CSL.Engine(new Zotero.Cite.System(automaticJournalAbbreviations), xml, locale);
|
return new Zotero.CiteProc.CSL.Engine(
|
||||||
|
new Zotero.Cite.System(automaticJournalAbbreviations),
|
||||||
|
xml,
|
||||||
|
locale,
|
||||||
|
overrideLocale
|
||||||
|
);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
throw e;
|
throw e;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user