summaryrefslogtreecommitdiffstats
path: root/vnc.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 /vnc.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 'vnc.py')
-rw-r--r--vnc.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/vnc.py b/vnc.py
index 3e5d8139c..db119d096 100644
--- a/vnc.py
+++ b/vnc.py
@@ -32,6 +32,7 @@ import subprocess
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
+P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z)
import logging
log = logging.getLogger("anaconda")
@@ -185,7 +186,9 @@ class VncServer:
else:
log.critical(err)
sys.exit(1)
- self.log.error(_("Giving up attempting to connect after %d tries!\n" % maxTries ))
+ self.log.error(P_("Giving up attempting to connect after %d try!\n",
+ "Giving up attempting to connect after %d tries!\n",
+ maxTries) % (maxTries,))
return False
def VNCListen(self):