Merge pull request #559 from aurimasv/patch-1
Allow dependent styles to override parent style locale
This commit is contained in:
commit
aa005041a8
1 changed files with 17 additions and 1 deletions
|
@ -448,6 +448,8 @@ Zotero.Style = function(arg) {
|
|||
for each(category in Zotero.Utilities.xpath(doc,
|
||||
'/csl:style/csl:info[1]/csl:category', Zotero.Styles.ns))
|
||||
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._usesAbbreviation = !!Zotero.Utilities.xpath(doc,
|
||||
'//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
|
||||
var overrideLocale = false; // to force dependent style locale
|
||||
if(this.source) {
|
||||
var parentStyle = Zotero.Styles.get(this.source);
|
||||
if(!parentStyle) {
|
||||
|
@ -485,6 +488,14 @@ Zotero.Style.prototype.getCiteProc = function(automaticJournalAbbreviations) {
|
|||
Zotero.Styles.ios.newFileURI(this.file).spec, null));
|
||||
}
|
||||
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 {
|
||||
var version = this._version;
|
||||
}
|
||||
|
@ -519,7 +530,12 @@ Zotero.Style.prototype.getCiteProc = function(automaticJournalAbbreviations) {
|
|||
}
|
||||
|
||||
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) {
|
||||
Zotero.logError(e);
|
||||
throw e;
|
||||
|
|
Loading…
Reference in a new issue