Show label of translator that causes import error (#2539)

This commit is contained in:
Abe Jellinek 2022-04-14 04:01:43 -07:00 committed by GitHub
parent 08d3880d88
commit 1538a836b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -654,7 +654,7 @@ var Zotero_File_Interface = new function() {
Zotero.alert(
null,
Zotero.getString('general.error'),
Zotero.getString("fileInterface.importError")
Zotero_File_Interface.makeImportErrorString(translation)
);
return false;
}
@ -1038,6 +1038,22 @@ var Zotero_File_Interface = new function() {
// polling executed by the main window because current (wizard) window will be closed
Zotero.getMainWindow().setTimeout(this.authenticateMendeleyOnlinePoll.bind(this, win), 200);
};
/**
* Generate an error string reporting a translation failure. Includes the
* label of the running translator if available.
*
* @param {Zotero.Translate} [translate]
* @return {String}
*/
this.makeImportErrorString = function (translate) {
let translatorLabel = translate?.translator
&& translate.translator[0]
&& translate.translator[0].label;
return translatorLabel
? Zotero.getString('fileInterface.importError.translator', translatorLabel)
: Zotero.getString('fileInterface.importError');
};
};
// Handles the display of a progress indicator

View file

@ -266,7 +266,7 @@ var Zotero_Import_Wizard = {
else {
this._onDone(
Zotero.getString('general.error'),
Zotero.getString('fileInterface.importError'),
Zotero_File_Interface.makeImportErrorString(this._translation),
true
);
}

View file

@ -774,6 +774,7 @@ fileInterface.viewSupportedFormats = View Supported Formats…
fileInterface.untitledBibliography = Untitled Bibliography
fileInterface.bibliographyHTMLTitle = Bibliography
fileInterface.importError = An error occurred while trying to import the selected file. Please ensure that the file is valid and try again.
fileInterface.importError.translator = An error occurred importing the selected file with “%S”. Please ensure that the file is valid and try again.
fileInterface.importClipboardNoDataError = No importable data could be read from the clipboard.
fileInterface.noReferencesError = The items you have selected contain no references. Please select one or more references and try again.
fileInterface.bibliographyGenerationError = An error occurred generating your bibliography. Please try again.