summaryrefslogtreecommitdiffstats
path: root/text.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 /text.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 'text.py')
-rw-r--r--text.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/text.py b/text.py
index 70a5331dc..3d1c63d4b 100644
--- a/text.py
+++ b/text.py
@@ -40,6 +40,7 @@ import imputil
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")
@@ -369,8 +370,12 @@ class LuksPassphraseWindow:
if len(passphrase) < self.minLength:
ButtonChoiceWindow(self.screen,
_("Error with passphrase"),
- _("The passphrase must be at least "
- "%d characters long.") % (self.minLength,),
+ P_("The passphrase must be at least "
+ "%d character long.",
+ "The passphrase must be at least "
+ "%d characters long.",
+ self.minLength)
+ % (self.minLength,),
buttons=[TEXT_OK_BUTTON])
passphraseentry.set("")
confirmentry.set("")