зеркало из https://github.com/mozilla/pjs.git
Bug 170514 - Language name representation not localizable. Patch by marcel.gosselin@polymtl.ca r=nhotta sr=jag a=asa
This commit is contained in:
Родитель
c5d10642c9
Коммит
271ceaef8c
|
@ -514,6 +514,9 @@ function convertLanguageCode(abbr)
|
|||
{
|
||||
if (!abbr) return "";
|
||||
var result;
|
||||
var language = "";
|
||||
var region;
|
||||
var is_region_set = false;
|
||||
var tokens = abbr.split("-");
|
||||
|
||||
if (tokens[0] === "x" || tokens[0] === "i")
|
||||
|
@ -525,13 +528,14 @@ function convertLanguageCode(abbr)
|
|||
if (tokens[0])
|
||||
{
|
||||
// Upper-case first letter
|
||||
result = tokens[0].substr(0, 1).toUpperCase() + tokens[0].substr(1);
|
||||
language = tokens[0].substr(0, 1).toUpperCase() + tokens[0].substr(1);
|
||||
tokens.shift();
|
||||
|
||||
if (tokens[0])
|
||||
{
|
||||
// Add on the rest as space-separated strings inside the brackets
|
||||
result += " (" + tokens.join(" ") + ")";
|
||||
region = tokens.join(" ");
|
||||
is_region_set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -541,12 +545,12 @@ function convertLanguageCode(abbr)
|
|||
// and the rest as strings.
|
||||
try
|
||||
{
|
||||
result = gLangBundle.getString(tokens[0]);
|
||||
language = gLangBundle.getString(tokens[0]);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// Language not present in lang bundle
|
||||
result = tokens[0];
|
||||
language = tokens[0];
|
||||
}
|
||||
|
||||
tokens.shift();
|
||||
|
@ -557,17 +561,32 @@ function convertLanguageCode(abbr)
|
|||
{
|
||||
// We don't add it on to the result immediately
|
||||
// because we want to get the spacing right.
|
||||
tokens[0] = gRegionBundle.getString(tokens[0].toLowerCase());
|
||||
region = gRegionBundle.getString(tokens[0].toLowerCase());
|
||||
|
||||
tokens.shift();
|
||||
|
||||
if (tokens[0])
|
||||
{
|
||||
// Add on the rest as space-separated strings inside the brackets
|
||||
region += " " + tokens.join(" ");
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
// Region not present in region bundle
|
||||
region = tokens.join(" ");
|
||||
}
|
||||
|
||||
result += " (" + tokens.join(" ") + ")";
|
||||
is_region_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_region_set) {
|
||||
result = gMetadataBundle.getFormattedString("languageRegionFormat",
|
||||
[language, region]);
|
||||
} else {
|
||||
result = language;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
sameWindowText=Same window
|
||||
newWindowText=New window
|
||||
parentFrameText=Parent frame
|
||||
sameFrameText=Same frame
|
||||
embeddedText=Embedded
|
||||
unableToShowProps=No properties available.
|
||||
altTextMissing=Missing
|
||||
altTextBlank=Blank
|
||||
imageSize=%S KB (%S bytes)
|
||||
imageSizeUnknown=Unknown (not cached)
|
||||
imageWidth=%Spx
|
||||
imageHeight=%Spx
|
|
@ -118,84 +118,89 @@ function AddLanguage()
|
|||
|
||||
function ReadAvailableLanguages()
|
||||
{
|
||||
availLanguageDict = new Array();
|
||||
var visible = new String();
|
||||
var str = new String();
|
||||
var i =0;
|
||||
|
||||
availLanguageDict = new Array();
|
||||
var visible = new String();
|
||||
var str = new String();
|
||||
var i =0;
|
||||
var acceptedBundleEnum = acceptedBundle.getSimpleEnumeration();
|
||||
|
||||
var acceptedBundleEnum = acceptedBundle.getSimpleEnumeration();
|
||||
|
||||
var curItem;
|
||||
var curItem;
|
||||
var stringName;
|
||||
var stringNameProperty;
|
||||
|
||||
while (acceptedBundleEnum.hasMoreElements()) {
|
||||
while (acceptedBundleEnum.hasMoreElements()) {
|
||||
|
||||
//progress through the bundle
|
||||
curItem = acceptedBundleEnum.getNext();
|
||||
//progress through the bundle
|
||||
curItem = acceptedBundleEnum.getNext();
|
||||
|
||||
//"unpack" the item, nsIPropertyElement is now partially scriptable
|
||||
curItem = curItem.QueryInterface(Components.interfaces.nsIPropertyElement);
|
||||
//"unpack" the item, nsIPropertyElement is now partially scriptable
|
||||
curItem = curItem.QueryInterface(Components.interfaces.nsIPropertyElement);
|
||||
|
||||
//dump string name (key)
|
||||
stringName = curItem.key;
|
||||
stringNameProperty = stringName.split('.');
|
||||
//dump string name (key)
|
||||
stringName = curItem.key;
|
||||
stringNameProperty = stringName.split('.');
|
||||
|
||||
if (stringNameProperty[1] == 'accept') {
|
||||
if (stringNameProperty[1] == 'accept') {
|
||||
|
||||
//dump the UI string (value)
|
||||
visible = curItem.value;
|
||||
//dump the UI string (value)
|
||||
visible = curItem.value;
|
||||
|
||||
//if (visible == 'true') {
|
||||
//if (visible == 'true') {
|
||||
|
||||
str = stringNameProperty[0];
|
||||
var stringLangRegion = stringNameProperty[0].split('-');
|
||||
str = stringNameProperty[0];
|
||||
var stringLangRegion = stringNameProperty[0].split('-');
|
||||
|
||||
if (stringLangRegion[0]) {
|
||||
var tit;
|
||||
try {
|
||||
tit = languagesBundle.GetStringFromName(stringLangRegion[0]);
|
||||
}
|
||||
if (stringLangRegion[0]) {
|
||||
var tit;
|
||||
var language;
|
||||
var region;
|
||||
var use_region_format = false;
|
||||
|
||||
catch (ex) {
|
||||
tit = "";
|
||||
}
|
||||
try {
|
||||
language = languagesBundle.GetStringFromName(stringLangRegion[0]);
|
||||
}
|
||||
catch (ex) {
|
||||
language = "";
|
||||
}
|
||||
|
||||
if (stringLangRegion.length > 1) {
|
||||
|
||||
if (stringLangRegion.length > 1) {
|
||||
try {
|
||||
region = regionsBundle.GetStringFromName(stringLangRegion[1]);
|
||||
use_region_format = true;
|
||||
}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
|
||||
if (use_region_format) {
|
||||
tit = prefLangBundle.formatStringFromName("languageRegionCodeFormat",
|
||||
[language, region, str], 3);
|
||||
} else {
|
||||
tit = prefLangBundle.formatStringFromName("languageCodeFormat",
|
||||
[language, str], 2);
|
||||
}
|
||||
|
||||
try {
|
||||
tit += "/" + regionsBundle.GetStringFromName(stringLangRegion[1]);
|
||||
}
|
||||
} //if language
|
||||
|
||||
catch (ex) {
|
||||
tit += "["+str+"]";
|
||||
}
|
||||
|
||||
} //if region
|
||||
|
||||
tit = tit + " [" + str + "]";
|
||||
|
||||
} //if language
|
||||
|
||||
if (str && tit) {
|
||||
if (str && tit) {
|
||||
|
||||
availLanguageDict[i] = new Array(3);
|
||||
availLanguageDict[i][0] = tit;
|
||||
availLanguageDict[i][1] = str;
|
||||
availLanguageDict[i][2] = visible;
|
||||
i++;
|
||||
i++;
|
||||
|
||||
} // if str&tit
|
||||
//} //if visible
|
||||
} //if accepted
|
||||
} //while
|
||||
availLanguageDict.sort( // sort on first element
|
||||
function (a, b) {
|
||||
if (a[0] < b[0]) return -1;
|
||||
if (a[0] > b[0]) return 1;
|
||||
return 0;
|
||||
} // if str&tit
|
||||
//} //if visible
|
||||
} //if accepted
|
||||
} //while
|
||||
availLanguageDict.sort( // sort on first element
|
||||
function (a, b) {
|
||||
if (a[0] < b[0]) return -1;
|
||||
if (a[0] > b[0]) return 1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
illegalOtherLanguage=The following entries were not valid language codes:
|
||||
illegalOtherLanguageTitle=Invalid language code(s)
|
Загрузка…
Ссылка в новой задаче