summaryrefslogtreecommitdiffstats
path: root/yuminstall.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-05-27 17:00:49 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-06-03 09:28:49 -1000
commit777301cc123cb78631939caad3038ade24d724b6 (patch)
treecb66b823d6ebc53f0728e0e9bd3ab6593d97315e /yuminstall.py
parent6104124defc97a4f65d31c1cc5c09e0716f6f3c1 (diff)
downloadanaconda-777301cc123cb78631939caad3038ade24d724b6.tar.gz
anaconda-777301cc123cb78631939caad3038ade24d724b6.tar.xz
anaconda-777301cc123cb78631939caad3038ade24d724b6.zip
Use gettext.ldngettext when necessary (#467603)
The i18n people have suggested using ngettext when we need to have singular and plural forms of strings, where the count will vary as to what we are reporting to the user. I've made the changes they have suggested. I created a new lambda function called P_() to use for the plural cases. P_() takes in three parameters: 1) The singular form of the string. 2) The plural form of the string. 3) A count. Here's an example: ....some loop runs doing stuff bytesWritten = 47 msg = P_("Wrote %d byte.", "Wrote %d bytes.", bytesWritten) % (bytesWritten,) print msg The % substitution is correct at the end because P_() returns a single string, so we only need the format string to account for that. Some strings have been changed slightly to make it easier for translations to other languages, particularly when choosing plural forms.
Diffstat (limited to 'yuminstall.py')
-rw-r--r--yuminstall.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/yuminstall.py b/yuminstall.py
index 34e3c1859..784cfb1f5 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -51,6 +51,7 @@ import packages
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
+P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z)
import network
@@ -81,10 +82,7 @@ def size_string (size):
size = size / 1024
retval = _("%s KB") %(number_format(size),)
else:
- if size == 1:
- retval = _("%s Byte") %(number_format(size),)
- else:
- retval = _("%s Bytes") %(number_format(size),)
+ retval = P_("%s Byte", "%s Bytes", size) % (number_format(size),)
return to_unicode(retval)
@@ -209,8 +207,10 @@ class AnacondaCallback:
self.doneFiles += len(hdr[rpm.RPMTAG_BASENAMES])
if self.donepkgs <= self.numpkgs:
- self.progress.set_text(_("%s of %s packages completed")
- %(self.donepkgs, self.numpkgs))
+ self.progress.set_text(P_("Packages completed: %d of %d",
+ "Packages completed: %d of %d",
+ self.numpkgs)
+ % (self.donepkgs, self.numpkgs,))
self.progress.set_fraction(float(self.doneSize / self.totalSize))
self.progress.processEvents()