diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index db5188bf3..1fd9f16ce 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -230,6 +230,7 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback callback(newItems); }); + translate.capitalizeTitles = false; // internal hack to call detect on this translator translate._potentialTranslators = [this._translator]; diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 1f46f677b..3b5b8da5d 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -498,7 +498,7 @@ Zotero.Utilities = { string = this.trimInternal(string); string = string.replace(/ : /g, ": "); - if(!Zotero.Prefs.get('capitalizeTitles') && !force) return string; + if(force === false || (!Zotero.Prefs.get('capitalizeTitles') && !force)) return string; if(!string) return ""; // split words @@ -783,6 +783,24 @@ Zotero.Utilities.Translate.prototype.strToISO = Zotero.Date.strToISO; Zotero.Utilities.Translate.prototype.createContextObject = Zotero.OpenURL.createContextObject; Zotero.Utilities.Translate.prototype.parseContextObject = Zotero.OpenURL.parseContextObject; +/** + * Hack to overloads {@link Zotero.Utilities.capitalizeTitle} to allow overriding capitalizeTitles + * pref on a per-translate instance basis (for translator testing only) + */ +Zotero.Utilities.Translate.prototype.capitalizeTitle = function(string, force) { + if(force === undefined) { + var translate = this._translate; + do { + if(translate.capitalizeTitles !== undefined) { + force = translate.capitalizeTitles; + break; + } + } while(translate = translate._parentTranslator); + } + + return Zotero.Utilities.capitalizeTitle(string, force); +} + /** * Gets the current Zotero version *