Bug 959061 - Have only one "Chinese, Simplified" item in the Character Encoding menu. r=Unfocused.

This commit is contained in:
Henri Sivonen 2014-01-30 14:39:25 +02:00
parent 0e6b7fff02
commit cf6bacb02c
4 changed files with 42 additions and 4 deletions

View File

@ -5221,12 +5221,23 @@ function UpdateCurrentCharset(target) {
pref_item.setAttribute('checked', 'false');
}
var menuitem = charsetMenuGetElement(target, "charset." + wnd.document.characterSet);
var menuitem = charsetMenuGetElement(target, "charset." + FoldCharset(wnd.document.characterSet));
if (menuitem) {
menuitem.setAttribute('checked', 'true');
}
}
function FoldCharset(charset) {
// For substantially similar encodings, treat two encodings as the same
// for the purpose of the check mark.
if (charset == "ISO-8859-8-I") {
return "windows-1255";
} else if (charset == "gb18030") {
return "gbk";
}
return charset;
}
function UpdateCharsetDetector(target) {
var prefvalue;
@ -5249,7 +5260,7 @@ function UpdateMenus(event) {
}
function charsetLoadListener() {
var charset = window.content.document.characterSet;
var charset = FoldCharset(window.content.document.characterSet);
if (charset.length > 0 && (charset != gLastBrowserCharset)) {
gPrevCharset = gLastBrowserCharset;

View File

@ -697,8 +697,19 @@ function SelectDetector(event)
}
}
function FoldCharset(charset) {
// For substantially similar encodings, treat two encodings as the same
// for the purpose of the check mark.
if (charset == "ISO-8859-8-I") {
return "windows-1255";
} else if (charset == "gb18030") {
return "gbk";
}
return charset;
}
function UpdateCurrentCharset() {
var menuitem = document.getElementById("charset." + content.document.characterSet);
var menuitem = document.getElementById("charset." + FoldCharset(content.document.characterSet));
if (menuitem)
menuitem.setAttribute("checked", "true");
}

View File

@ -6,6 +6,9 @@
# Localizations may add or delete properties where the property key ends with
# ".key" as appropriate for the localization. The code that uses this data can
# deal with the absence of an access key for an item.
#
# For gbk, gbk.bis and gbk.bis.key are used to trigger string changes in
# localizations.
#
# Make sure the keys defined here don't collide with
# charsetMenuAutodet.accesskey in charsetMenu.dtd.
@ -61,6 +64,12 @@ ISO-8859-2.key = l
ISO-8859-2 = Central European (ISO)
# Chinese, Simplified
# LOCALIZATION NOTE (gbk.bis.key):
# gbk.bis.key never appears together with gbk.key and, hence, can be the same.
gbk.bis.key = S
gbk.bis = Chinese, Simplified
# The strings gbk.key, gbk and gb18030 are no longer used but are retained
# in order to enable backout after string freeze, just in case.
gbk.key = S
gbk = Chinese, Simplified (GBK)
gb18030 = Chinese, Simplified (GB18030)

View File

@ -44,7 +44,6 @@ const kEncodings = new Set([
"ISO-8859-2",
// Chinese, Simplified
"gbk",
"gb18030",
// Chinese, Traditional
"Big5",
// Cyrillic
@ -217,12 +216,20 @@ let CharsetMenu = {
},
_getCharsetLabel: function(charset) {
if (charset == "gbk") {
// Localization key has been revised
charset = "gbk.bis";
}
try {
return gBundle.GetStringFromName(charset);
} catch (ex) {}
return charset;
},
_getCharsetAccessKey: function(charset) {
if (charset == "gbk") {
// Localization key has been revised
charset = "gbk.bis";
}
try {
accesskey = gBundle.GetStringFromName(charset + ".key");
} catch (ex) {}