r415 - trunk/scripts
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Jan 14 03:38:53 EST 2008
Author: icculus
Date: 2008-01-14 03:38:53 -0500 (Mon, 14 Jan 2008)
New Revision: 415
Modified:
trunk/scripts/localization.lua
trunk/scripts/mojosetup_mainline.lua
Log:
Cleaned up localization for download progress text.
Modified: trunk/scripts/localization.lua
===================================================================
--- trunk/scripts/localization.lua 2008-01-14 08:38:19 UTC (rev 414)
+++ trunk/scripts/localization.lua 2008-01-14 08:38:53 UTC (rev 415)
@@ -276,6 +276,26 @@
["KB/s"] = {
};
+ -- Download rate when we don't know the goal (can't report time left).
+ -- This is a number ($0) followed by the localized "KB/s" or "B/s" ($1).
+ ["$0 $1"] = {
+ };
+
+ -- Download rate when we know the goal (can report time left).
+ -- This is a number ($0) followed by the localized "KB/s" or "B/s" ($1),
+ -- then the hours ($2), minutes ($3), and seconds ($4) remaining
+ ["$0 $1, $2:$3:$4 remaining"] = {
+ };
+
+ -- download rate when download isn't progressing at all.
+ ["stalled"] = {
+ };
+
+ -- Download progress string: filename ($0), percent downloaded ($1),
+ -- download rate determined in one of the above strings ($2).
+ ["$0: $1%% ($2)"] = {
+ };
+
["Media change"] = {
};
@@ -325,10 +345,6 @@
["Shutting down..."] = {
};
- -- printed instead of kilobytes per second when download isn't progressing.
- ["(stalled)"] = {
- };
-
["Symlink creation failed!"] = {
};
Modified: trunk/scripts/mojosetup_mainline.lua
===================================================================
--- trunk/scripts/mojosetup_mainline.lua 2008-01-14 08:38:19 UTC (rev 414)
+++ trunk/scripts/mojosetup_mainline.lua 2008-01-14 08:38:53 UTC (rev 415)
@@ -139,44 +139,42 @@
end
-local function make_bps_string(bps, bw, total)
- -- !!! FIXME: localization on all this.
- local bpsstr = nil
+local function make_rate_string(rate, bw, total)
+ local retval = nil
- if bps <= 0 then
- bpsstr = _("(stalled)")
+ if rate <= 0 then
+ retval = _("stalled")
else
- local bytesleft = total - bw
- local secsleft = MojoSetup.truncatenum(bytesleft / bps)
- local minsleft = MojoSetup.truncatenum(secsleft / 60)
- local hoursleft = MojoSetup.truncatenum(minsleft / 60)
+ local ratetype = _("B/s")
+ if rate > 1024 then
+ rate = MojoSetup.truncatenum(rate / 1024)
+ ratetype = _("KB/s")
+ end
- secsleft = string.sub("00" .. (secsleft - (minsleft * 60)), -2)
- minsleft = string.sub("00" .. (minsleft - (hoursleft * 60)), -2)
+ if total > 0 then -- can approximate time left if we know the goal.
+ local bytesleft = total - bw
+ local secsleft = MojoSetup.truncatenum(bytesleft / rate)
+ local minsleft = MojoSetup.truncatenum(secsleft / 60)
+ local hoursleft = MojoSetup.truncatenum(minsleft / 60)
- if hoursleft < 10 then
- hoursleft = "0" .. hoursleft
- else
- hoursleft = tostring(hoursleft)
- end
+ secsleft = string.sub("00" .. (secsleft - (minsleft * 60)), -2)
+ minsleft = string.sub("00" .. (minsleft - (hoursleft * 60)), -2)
- local timeleft = hoursleft .. ":" .. minsleft .. ":" .. secsleft
- if bps > 1024 then
- local kps = MojoSetup.truncatenum(bps / 1024)
- if total > 0 then
- bpsstr = " (" .. kps .. _("Kb/s") .. ", " .. timeleft .. " remaining)"
+ if hoursleft < 10 then
+ hoursleft = "0" .. hoursleft
else
- bpsstr = " (" .. kps .. _("Kb/s") .. ")"
+ hoursleft = tostring(hoursleft)
end
+
+ retval = MojoSetup.format(_("$0 $1, $2:$3:$4 remaining"),
+ rate, ratetype,
+ hoursleft, minsleft, secsleft)
else
- if total > 0 then
- bpsstr = " (" .. bps .. _("b/s") .. ", " .. timeleft .. " remaining)"
- else
- bpsstr = " (" .. bps .. _("b/s") .. ")"
- end
+ retval = MojoSetup.format(_("$0 $1"), rate, ratetype)
end
end
- return bpsstr
+
+ return retval
end
@@ -1089,7 +1087,7 @@
local component = option.description
local bps = 0
local bpsticks = 0
- local bpsstr = ''
+ local ratestr = ''
local item = fname
local percent = -1
local callback = function(ticks, justwrote, bw, total)
@@ -1098,7 +1096,7 @@
bpsticks = ticks + 1000
else
if ticks >= bpsticks then
- bpsstr = make_bps_string(bps, bw, total)
+ ratestr = make_rate_string(bps, bw, total)
bpsticks = ticks + 1000
bps = 0
end
@@ -1107,7 +1105,10 @@
percent = calc_percent(MojoSetup.downloaded,
MojoSetup.totaldownload)
- item = fname .. ": " .. calc_percent(bw, total) .. "%" .. bpsstr -- !!! FIXME: localization
+ item = MojoSetup.format(_("$0: $1%% ($2)"),
+ fname,
+ calc_percent(bw, total),
+ ratestr);
end
return MojoSetup.gui.progress(ptype, component, percent, item)
end
More information about the mojosetup-commits
mailing list