commit aa005041a8d06933ab772f1b87b7c84b72a05912
parent a737f2c2aa7927d605523d4941cf7ce5577a91b0
Author: Simon Kornblith <simon@simonster.com>
Date: Thu, 23 Oct 2014 20:17:42 -0400
Merge pull request #559 from aurimasv/patch-1
Allow dependent styles to override parent style locale
Diffstat:
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/style.js b/chrome/content/zotero/xpcom/style.js
@@ -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;