Save translator names as ASCII during repo updates as well
Refs #459, Non-ascii translator names
This commit is contained in:
parent
020eaf2d47
commit
dee75dd417
2 changed files with 17 additions and 15 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue