diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js index 6f0a4012e..ba2a6e179 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/translate.js +++ b/chrome/chromeFiles/content/scholar/xpcom/translate.js @@ -876,6 +876,8 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) if(this.type == "search" && !this._itemsFound && this.translator.length > 1) { // if we're performing a search and didn't get any results, go on // to the next translator + Scholar.debug("could not find a result using "+this.translator[0].label+": \n" + +this._generateErrorString(error)); this.translator.shift(); this.translate(); } else { @@ -897,23 +899,7 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) this._runHandler("done", returnValue); if(!returnValue) { - var errorString = ""; - if(typeof(error) == "string") { - errorString = "\nthrown exception => "+error; - } else { - for(var i in error) { - if(typeof(error[i]) != "object") { - errorString += "\n"+i+' => '+error[i]; - } - } - } - - errorString += "\nurl => "+this.path - + "\nextensions.zotero.cacheTranslatorData => "+Scholar.Prefs.get("cacheTranslatorData") - + "\nextensions.zotero.downloadAssociatedFiles => "+Scholar.Prefs.get("downloadAssociatedFiles"); - - errorString = errorString.substr(1); - + var errorString = this._generateErrorString(error); Scholar.debug("translation using "+this.translator[0].label+" failed: \n"+errorString); if(this.type == "web") { @@ -927,6 +913,27 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) } } +/* + * generates a useful error string, for submitting and debugging purposes + */ +Scholar.Translate.prototype._generateErrorString = function(error) { + var errorString = ""; + if(typeof(error) == "string") { + errorString = "\nthrown exception => "+error; + } else { + for(var i in error) { + if(typeof(error[i]) != "object") { + errorString += "\n"+i+' => '+error[i]; + } + } + } + + errorString += "\nurl => "+this.path + + "\nextensions.zotero.cacheTranslatorData => "+Scholar.Prefs.get("cacheTranslatorData") + + "\nextensions.zotero.downloadAssociatedFiles => "+Scholar.Prefs.get("downloadAssociatedFiles"); + return errorString.substr(1); +} + /* * runs an HTTP request to report a translation error */ diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js index a1f190237..550dd7b56 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/utilities.js +++ b/chrome/chromeFiles/content/scholar/xpcom/utilities.js @@ -158,6 +158,7 @@ Scholar.Utilities.capitalizeSkipWords = ["but", "or", "yet", "so", "for", "and", "nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to", "with", "up", "down"]; Scholar.Utilities.prototype.capitalizeTitle = function(title) { + title = this.cleanString(title); title = title.replace(/ : /g, ": "); var words = title.split(" "); @@ -172,7 +173,7 @@ Scholar.Utilities.prototype.capitalizeTitle = function(title) { for(var i=1; i