Closes #1852: Test success may depend on capitalizeTitles preference

This commit is contained in:
Simon Kornblith 2011-07-04 17:05:42 +00:00
parent 763d46a565
commit fb87bded88
2 changed files with 20 additions and 1 deletions

View file

@ -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];

View file

@ -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
*