Bug 388506 - Use emdash for download status [time — progress (rate)]. Patch by Edward Lee <edilee@mozilla.com>. r=sdwilsh

This commit is contained in:
sdwilsh@shawnwilsher.com 2007-07-19 20:30:54 -07:00
Родитель 83ad8cbb2c
Коммит 7a84662b0b
2 изменённых файлов: 32 добавлений и 46 удалений

Просмотреть файл

@ -20,19 +20,28 @@ dontQuitButtonMac=Don't Quit
dontGoOfflineButton=Stay Online
downloadsCompleteTitle=Downloads Complete
downloadsCompleteMsg=All files have finished downloading.
transferSameUnits=#1 of #3 #4
transferDiffUnits=#1 #2 of #3 #4
transferNoTotal=#1 #2
remain=remain
unknownTimeLeft=unknown time left
statusFormat=#1 at #2 #3/sec; #4
longTimeFormat=#1:#2:#3
shortTimeFormat=#2:#3
# — is the "em dash" (long dash)
# #1 transfer progress; #2 rate number; #3 rate unit; #4 time left
# example: 4 minutes left — 1.1 of 11.1 GB (2.2 MB/sec)
statusFormat=#4 — #1 (#2 #3/sec)
bytes=bytes
kilobyte=KB
megabyte=MB
gigabyte=GB
# #1 progress number; #2 progress unit; #3 total number; #4 total unit
# examples: 1.1 of 333 MB; 11.1 MB of 3.3 GB; 111 KB
transferSameUnits=#1 of #3 #4
transferDiffUnits=#1 #2 of #3 #4
transferNoTotal=#1 #2
# #1 minutes left (greater than 1)
# example: 11 minutes left
timeLeft=#1 minutes left
timeLessMinute=Less than a minute
timeUnknown=Unknown time left
fileDoesNotExistOpenTitle=Cannot Open %S
fileDoesNotExistShowTitle=Cannot Show %S
fileDoesNotExistError=%S does not exist. It may have been renamed, moved, or deleted since it was downloaded.

Просмотреть файл

@ -48,10 +48,9 @@ function DownloadProgressListener (aDocument, aStringBundle)
this._transferSameUnits = aStringBundle.getString("transferSameUnits");
this._transferDiffUnits = aStringBundle.getString("transferDiffUnits");
this._transferNoTotal = aStringBundle.getString("transferNoTotal");
this._remain = aStringBundle.getString("remain");
this._unknownTimeLeft = aStringBundle.getString("unknownTimeLeft");
this._longTimeFormat = aStringBundle.getString("longTimeFormat");
this._shortTimeFormat = aStringBundle.getString("shortTimeFormat");
this._timeLeft = aStringBundle.getString("timeLeft");
this._timeLessMinute = aStringBundle.getString("timeLessMinute");
this._timeUnknown = aStringBundle.getString("timeUnknown");
this._units = [aStringBundle.getString("bytes"),
aStringBundle.getString("kilobyte"),
aStringBundle.getString("megabyte"),
@ -148,11 +147,16 @@ DownloadProgressListener.prototype =
// Update time remaining.
let (remain) {
if ((aDownload.speed > 0) && (aMaxTotalProgress > 0))
remain = this._formatSeconds((aMaxTotalProgress - aCurTotalProgress) /
aDownload.speed) + " " + this._remain;
if ((aDownload.speed > 0) && (aMaxTotalProgress > 0)) {
let minutes = Math.ceil((aMaxTotalProgress - aCurTotalProgress) /
aDownload.speed / 60);
if (minutes > 1)
remain = this._replaceInsert(this._timeLeft, 1, minutes);
else
remain = this._unknownTimeLeft;
remain = this._timeLessMinute;
} else {
remain = this._timeUnknown;
}
// Insert 4 is the time remaining
status = this._replaceInsert(status, 4, remain);
@ -206,32 +210,5 @@ DownloadProgressListener.prototype =
aBytes = aBytes.toFixed((aBytes > 0) && (aBytes < 100) ? 1 : 0);
return [aBytes, this._units[unitIndex]];
},
_formatSeconds: function (secs, doc)
{
// Round the number of seconds to remove fractions.
secs = parseInt(secs + .5);
var hours = parseInt(secs/3600);
secs -= hours * 3600;
var mins = parseInt(secs/60);
secs -= mins * 60;
var result = hours ? this._longTimeFormat : this._shortTimeFormat;
if (hours < 10)
hours = "0" + hours;
if (mins < 10)
mins = "0" + mins;
if (secs < 10)
secs = "0" + secs;
// Insert hours, minutes, and seconds into result string.
result = this._replaceInsert(result, 1, hours);
result = this._replaceInsert(result, 2, mins);
result = this._replaceInsert(result, 3, secs);
return result;
}
};