Show only UTF-8, UTF-8 w/o BOM, and Western for export charsets
See https://forums.zotero.org/discussion/comment/263644/#Comment_263644 We might want to consider removing the export charset checkbox in the prefs and either always showing the charset option for translators or always showing it for BibTeX (where "Western" really means "ASCII") but nothing else. Fixes #1124
This commit is contained in:
parent
5a6f1eef63
commit
0609b62a39
1 changed files with 63 additions and 52 deletions
|
@ -39,65 +39,76 @@ var Zotero_Charset_Menu = new function() {
|
||||||
// get charset popup and charset RDF
|
// get charset popup and charset RDF
|
||||||
var charsetPopup = document.createElement("menupopup");
|
var charsetPopup = document.createElement("menupopup");
|
||||||
charsetMenu.appendChild(charsetPopup);
|
charsetMenu.appendChild(charsetPopup);
|
||||||
var charsetSeparator = document.createElement("menuseparator");
|
|
||||||
charsetPopup.appendChild(charsetSeparator);
|
|
||||||
|
|
||||||
var charsets = [];
|
var charsets = [];
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/CharsetMenu.jsm");
|
// Only list UTF-8 and Western for export
|
||||||
var cmData = CharsetMenu.getData();
|
if (exportMenu) {
|
||||||
for (let charsetList of [cmData.pinnedCharsets, cmData.otherCharsets]) {
|
charsets.push(
|
||||||
for each(var charsetInfo in charsetList) {
|
{ label: "Unicode (UTF-8)", value: "UTF-8" },
|
||||||
if(charsetInfo.value == "UTF-8") {
|
{ label: Zotero.getString("charset.UTF8withoutBOM"), value: "UTF-8xBOM" },
|
||||||
charsets.push({
|
{ label: "Western", value: "windows-1252" }
|
||||||
"label":"Unicode (UTF-8)",
|
);
|
||||||
"value":"UTF-8"
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
charsets.push({
|
|
||||||
"label":charsetInfo.label,
|
|
||||||
"value":charsetInfo.value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
charsets = charsets.concat([
|
|
||||||
{"label":"UTF-16LE", "value":"UTF-16LE"},
|
|
||||||
{"label":"UTF-16BE", "value":"UTF-16BE"},
|
|
||||||
{"label":"Western (IBM-850)", "value":"IBM850"},
|
|
||||||
{"label":"Western (MacRoman)", "value":"macintosh"}
|
|
||||||
]);
|
|
||||||
|
|
||||||
for(var i=0; i<charsets.length; i++) {
|
|
||||||
var charset = charsets[i].value,
|
|
||||||
label = charsets[i].label;
|
|
||||||
|
|
||||||
// add element
|
|
||||||
var itemNode = document.createElement("menuitem");
|
|
||||||
itemNode.setAttribute("label", label);
|
|
||||||
itemNode.setAttribute("value", charset);
|
|
||||||
|
|
||||||
charsetMap[charset] = itemNode;
|
for (let charset of charsets) {
|
||||||
if(isUTF16 || (label.length >= 7 &&
|
let { label, value } = charset;
|
||||||
label.substr(0, 7) == "Western")) {
|
|
||||||
charsetPopup.insertBefore(itemNode, charsetSeparator);
|
let itemNode = document.createElement("menuitem");
|
||||||
} else if(charset == "UTF-8") {
|
itemNode.setAttribute("label", label);
|
||||||
var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null);
|
itemNode.setAttribute("value", value);
|
||||||
charsetPopup.insertBefore(itemNode, oldFirst);
|
|
||||||
// also add (without BOM) if requested
|
charsetMap[value] = itemNode;
|
||||||
if(exportMenu) {
|
|
||||||
var itemNode = document.createElement("menuitem");
|
|
||||||
itemNode.setAttribute("label", Zotero.getString("charset.UTF8withoutBOM"));
|
|
||||||
itemNode.setAttribute("value", charset+"xBOM");
|
|
||||||
charsetMap[charset+"xBOM"] = itemNode;
|
|
||||||
charsetPopup.insertBefore(itemNode, oldFirst);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
charsetPopup.appendChild(itemNode);
|
charsetPopup.appendChild(itemNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var charsetSeparator = document.createElement("menuseparator");
|
||||||
|
charsetPopup.appendChild(charsetSeparator);
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/CharsetMenu.jsm");
|
||||||
|
var cmData = CharsetMenu.getData();
|
||||||
|
for (let charsetList of [cmData.pinnedCharsets, cmData.otherCharsets]) {
|
||||||
|
for each(var charsetInfo in charsetList) {
|
||||||
|
if(charsetInfo.value == "UTF-8") {
|
||||||
|
charsets.push({
|
||||||
|
"label":"Unicode (UTF-8)",
|
||||||
|
"value":"UTF-8"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
charsets.push({
|
||||||
|
"label":charsetInfo.label,
|
||||||
|
"value":charsetInfo.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
charsets = charsets.concat([
|
||||||
|
{"label":"UTF-16LE", "value":"UTF-16LE"},
|
||||||
|
{"label":"UTF-16BE", "value":"UTF-16BE"},
|
||||||
|
{"label":"Western (IBM-850)", "value":"IBM850"},
|
||||||
|
{"label":"Western (MacRoman)", "value":"macintosh"}
|
||||||
|
]);
|
||||||
|
|
||||||
if(!exportMenu) {
|
for(var i=0; i<charsets.length; i++) {
|
||||||
|
var charset = charsets[i].value,
|
||||||
|
label = charsets[i].label;
|
||||||
|
|
||||||
|
// add element
|
||||||
|
var itemNode = document.createElement("menuitem");
|
||||||
|
itemNode.setAttribute("label", label);
|
||||||
|
itemNode.setAttribute("value", charset);
|
||||||
|
|
||||||
|
charsetMap[charset] = itemNode;
|
||||||
|
if (label.length >= 7 && label.substr(0, 7) == "Western") {
|
||||||
|
charsetPopup.insertBefore(itemNode, charsetSeparator);
|
||||||
|
} else if(charset == "UTF-8") {
|
||||||
|
var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null);
|
||||||
|
charsetPopup.insertBefore(itemNode, oldFirst);
|
||||||
|
} else {
|
||||||
|
charsetPopup.appendChild(itemNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var itemNode = document.createElement("menuitem");
|
var itemNode = document.createElement("menuitem");
|
||||||
itemNode.setAttribute("label", Zotero.getString("charset.autoDetect"));
|
itemNode.setAttribute("label", Zotero.getString("charset.autoDetect"));
|
||||||
itemNode.setAttribute("value", "auto");
|
itemNode.setAttribute("value", "auto");
|
||||||
|
|
Loading…
Reference in a new issue