Merge lp:~evfool/update-manager/lp351665 into lp:update-manager

Proposed by Robert Roth
Status: Merged
Merged at revision: 2320
Proposed branch: lp:~evfool/update-manager/lp351665
Merge into: lp:update-manager
Diff against target: 34 lines (+7/-8)
1 file modified
UpdateManager/Core/utils.py (+7/-8)
To merge this branch: bzr merge lp:~evfool/update-manager/lp351665
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+90569@code.launchpad.net

Description of the change

Use ngettext to localize humanized size, because some languages use separate singular and plural for x kB. (LP: #351665)

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks a lot! merged now, I added a small testcase.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UpdateManager/Core/utils.py'
--- UpdateManager/Core/utils.py 2012-01-25 16:59:26 +0000
+++ UpdateManager/Core/utils.py 2012-01-28 06:30:29 +0000
@@ -20,7 +20,9 @@
20# USA20# USA
2121
22from gettext import gettext as _22from gettext import gettext as _
23from gettext import ngettext
23from stat import (S_IMODE, ST_MODE, S_IXUSR)24from stat import (S_IMODE, ST_MODE, S_IXUSR)
25from math import ceil
2426
25import apt_pkg27import apt_pkg
26apt_pkg.init_config()28apt_pkg.init_config()
@@ -387,15 +389,12 @@
387 """389 """
388 Convert a given size in bytes to a nicer better readable unit390 Convert a given size in bytes to a nicer better readable unit
389 """391 """
390 if bytes == 0:392
391 # TRANSLATORS: download size is 0393 if bytes < 1000 * 1000:
392 return _("0 kB")394 # to have 0 for 0 bytes, 1 for 0-1000 bytes and for 1 and above round up
393 elif bytes < 1000:395 size_in_kb = int(ceil(bytes/float(1000)));
394 # TRANSLATORS: download size of very small updates
395 return _("1 kB")
396 elif bytes < 1000 * 1000:
397 # TRANSLATORS: download size of small updates, e.g. "250 kB"396 # TRANSLATORS: download size of small updates, e.g. "250 kB"
398 return locale.format_string(_("%.0f kB"), bytes/1000)397 return ngettext("%(size).0f kB", "%(size).0f kB", size_in_kb) % { "size" : size_in_kb }
399 else:398 else:
400 # TRANSLATORS: download size of updates, e.g. "2.3 MB"399 # TRANSLATORS: download size of updates, e.g. "2.3 MB"
401 return locale.format_string(_("%.1f MB"), bytes / 1000.0 / 1000.0)400 return locale.format_string(_("%.1f MB"), bytes / 1000.0 / 1000.0)

Subscribers

People subscribed via source and target branches

to status/vote changes: