mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1009795 - Part 2: Revert to the old gDecimalSymbol hack if the Internationalization API is not available; r=mak
This will be removed in bug 1200494.
This commit is contained in:
parent
68e13b0044
commit
69a48c438f
@ -46,6 +46,11 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
|
||||
this.__defineGetter__("gDecimalSymbol", function() {
|
||||
delete this.gDecimalSymbol;
|
||||
return this.gDecimalSymbol = Number(5.4).toLocaleString().match(/\D/);
|
||||
});
|
||||
|
||||
let localeNumberFormatCache = new Map();
|
||||
function getLocaleNumberFormat(fractionDigits) {
|
||||
// Backward compatibility: don't use localized digits
|
||||
@ -478,8 +483,13 @@ this.DownloadUtils = {
|
||||
if (aBytes === Infinity) {
|
||||
aBytes = "Infinity";
|
||||
} else {
|
||||
aBytes = getLocaleNumberFormat(fractionDigits)
|
||||
.format(aBytes);
|
||||
if (Intl) {
|
||||
aBytes = getLocaleNumberFormat(fractionDigits)
|
||||
.format(aBytes);
|
||||
} else if (gDecimalSymbol != ".") {
|
||||
// FIXME: Fall back to the old hack, will be fixed in bug 1200494.
|
||||
aBytes = aBytes.toFixed(fractionDigits).replace(".", gDecimalSymbol);
|
||||
}
|
||||
}
|
||||
|
||||
return [aBytes, gBundle.GetStringFromName(gStr.units[unitIndex])];
|
||||
|
Loading…
Reference in New Issue
Block a user