Bug 734862 - Replace "Infinite GB/s" with a more readable localized string. r=mak

This commit is contained in:
Sachin Hosmani 2013-05-22 18:53:11 +05:30
parent 2cc63f9019
commit 5071a621a9
3 changed files with 28 additions and 4 deletions

View File

@ -44,11 +44,20 @@ dontLeavePrivateBrowsingButton=Stay in Private Browsing Mode
downloadsCompleteTitle=Downloads Complete
downloadsCompleteMsg=All files have finished downloading.
# LOCALIZATION NOTE (infiniteRate):
# If download speed is a JavaScript Infinity value, this phrase is used
infiniteRate=Really fast
# LOCALIZATION NOTE (statusFormat3): — is the "em dash" (long dash)
# %1$S transfer progress; %2$S rate number; %3$S rate unit; %4$S time left
# example: 4 minutes left — 1.1 of 11.1 GB (2.2 MB/sec)
statusFormat3=%4$S — %1$S (%2$S %3$S/sec)
# LOCALIZATION NOTE (statusFormatInfiniteRate): — is the "em dash" (long dash)
# %1$S transfer progress; %2$S substitute phrase for Infinity speed; %3$S time left
# example: 4 minutes left — 1.1 of 11.1 GB (Really fast)
statusFormatInfiniteRate=%3$S — %1$S (%2$S)
# LOCALIZATION NOTE (statusFormatNoRate): — is the "em dash" (long dash)
# %1$S transfer progress; %2$S time left
# example: 4 minutes left — 1.1 of 11.1 GB

View File

@ -55,6 +55,7 @@ const kDownloadProperties =
let gStr = {
statusFormat: "statusFormat3",
statusFormatInfiniteRate: "statusFormatInfiniteRate",
statusFormatNoRate: "statusFormatNoRate",
transferSameUnits: "transferSameUnits2",
transferDiffUnits: "transferDiffUnits2",
@ -71,6 +72,7 @@ let gStr = {
units: ["bytes", "kilobyte", "megabyte", "gigabyte"],
// Update timeSize in convertTimeUnits if changing the length of this array
timeUnits: ["seconds", "minutes", "hours", "days"],
infiniteRate: "infiniteRate",
};
// This lazily initializes the string bundle upon first use.
@ -108,9 +110,19 @@ this.DownloadUtils = {
= this._deriveTransferRate(aCurrBytes, aMaxBytes, aSpeed, aLastSec);
let [rate, unit] = DownloadUtils.convertByteUnits(normalizedSpeed);
let params = [transfer, rate, unit, timeLeft];
let status = gBundle.formatStringFromName(gStr.statusFormat, params,
params.length);
let status;
if (rate === "Infinity") {
// Infinity download speed doesn't make sense. Show a localized phrase instead.
let params = [transfer, gBundle.GetStringFromName(gStr.infiniteRate), timeLeft];
status = gBundle.formatStringFromName(gStr.statusFormatInfiniteRate, params,
params.length);
}
else {
let params = [transfer, rate, unit, timeLeft];
status = gBundle.formatStringFromName(gStr.statusFormat, params,
params.length);
}
return [status, newLast];
},

View File

@ -26,7 +26,7 @@ function testTransferTotal(aCurrBytes, aMaxBytes, aTransfer)
// Get the em-dash character because typing it directly here doesn't work :(
let gDash = DownloadUtils.getDownloadStatus(0)[0].match(/remaining (.) 0 bytes/)[1];
let gVals = [0, 100, 2345, 55555, 982341, 23194134, 1482, 58, 9921949201, 13498132];
let gVals = [0, 100, 2345, 55555, 982341, 23194134, 1482, 58, 9921949201, 13498132, Infinity];
function testStatus(aFunc, aCurr, aMore, aRate, aTest)
{
@ -167,6 +167,9 @@ function run_test()
testStatus(statusFunc, 6, 6, 0, ["Unknown time remaining -- 1.4 of 2.9 KB (0 bytes/sec)", Infinity]);
testStatus(statusFunc, 8, 5, 0, ["Unknown time remaining -- 9.2 of 9.3 GB (0 bytes/sec)", Infinity]);
// With rate equal to Infinity
testStatus(statusFunc, 0, 0, 10, ["Unknown time remaining -- 0 of 0 bytes (Really fast)", Infinity]);
testStatus(statusFunc, 1, 2, 10, ["A few seconds remaining -- 100 bytes of 2.4 KB (Really fast)", 0]);
// Now test without rates, via getDownloadStatusNoRate.
statusFunc = DownloadUtils.getDownloadStatusNoRate.bind(DownloadUtils);