diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 64ebf93df..86fb3b688 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -692,12 +692,9 @@ Zotero.Schema = new function(){ } } - var fileName = Zotero.Utilities.removeDiacritics( - Zotero.File.getValidFileName(entry.label)) + fileExt; - // Use translatorID if name still isn't ASCII (e.g., Cyrillic) - if (!fileName.match(/^[\x00-\x7f]+$/)) { - fileName = translatorID + fileExt; - } + var fileName = Zotero.Translators.getFileNameFromLabel( + entry.label, translatorID + ); var destFile = destDir.clone(); destFile.append(fileName); @@ -820,12 +817,9 @@ Zotero.Schema = new function(){ } if (mode == 'translator') { - var fileName = Zotero.Utilities.removeDiacritics( - Zotero.File.getValidFileName(newObj[titleField])) + fileExt; - // Use translatorID if name still isn't ASCII (e.g., Cyrillic) - if (!fileName.match(/^[\x00-\x7f]+$/)) { - fileName = newObj.translatorID + fileExt; - } + var fileName = Zotero.Translators.getFileNameFromLabel( + newObj[titleField], newObj.translatorID + ); } else if (mode == 'style') { var fileName = file.leafName; diff --git a/chrome/content/zotero/xpcom/translation/translator.js b/chrome/content/zotero/xpcom/translation/translator.js index cc933bc88..5774358ac 100644 --- a/chrome/content/zotero/xpcom/translation/translator.js +++ b/chrome/content/zotero/xpcom/translation/translator.js @@ -305,8 +305,14 @@ Zotero.Translators = new function() { * @param {String} label * @return {String} */ - this.getFileNameFromLabel = function(label) { - return Zotero.File.getValidFileName(label) + ".js"; + this.getFileNameFromLabel = function(label, alternative) { + var fileName = Zotero.Utilities.removeDiacritics( + Zotero.File.getValidFileName(label)) + ".js"; + // Use translatorID if name still isn't ASCII (e.g., Cyrillic) + if (alternative && !fileName.match(/^[\x00-\x7f]+$/)) { + fileName = alternative + ".js"; + } + return fileName; } /** @@ -361,7 +367,9 @@ Zotero.Translators = new function() { throw ("code not provided in Zotero.Translators.save()"); } - var fileName = Zotero.Translators.getFileNameFromLabel(metadata.label); + var fileName = Zotero.Translators.getFileNameFromLabel( + metadata.label, metadata.translatorID + ); var destFile = Zotero.getTranslatorsDirectory(); destFile.append(fileName);