diff options
| author | Georg Bauer <gb@hugo.westfalen.de> | 2005-10-01 12:56:12 +0000 |
|---|---|---|
| committer | Georg Bauer <gb@hugo.westfalen.de> | 2005-10-01 12:56:12 +0000 |
| commit | 26bc142f8727e694aae79c690a0549d28b0bb2d9 (patch) | |
| tree | 5b5fd2e786f7600e9430f38f198622ee76ace9ae | |
| parent | 4eb73a35848bb31e84ee6ae002224ba5023968b4 (diff) | |
i18n: updated the documentation to list ngettext
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@756 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | docs/translation.txt | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/docs/translation.txt b/docs/translation.txt index 95272ae35d..8c90e51b9b 100644 --- a/docs/translation.txt +++ b/docs/translation.txt @@ -50,7 +50,6 @@ languages might require a reordering of text. The other two helper functions are similar in use:: - def hello_world(request, name, site): from django.utils.translation import gettext page = gettext('Hello %(name)s, welcome to %(site)s!') % { @@ -69,6 +68,16 @@ they are exchanged over systems or users - like strings in a database - but should be translated at the last possible point in time, when the string is presented to the user. +There is a standard problem with translations, that is pluralization of +strings. This is done by the standard helper ngettext like so:: + + def hello_world(request, count): + from django.utils.translation import ngettext + page = ngettext('there is %(count)d object', 'there are %(count)d objects', count) % { + 'count': count, + } + return page + Using Translations in Templates =============================== @@ -80,6 +89,7 @@ as with your source:: <title>{% i18n _('This is the title.') %}</title> <body> <p>{% i18n _('Hello %(name)s, welcome at %(site)s!') %}</p> + <p>{% i18n ngettext('There is %(count)d file', 'There are %(count)d files', files|count) %}</p> </body> </html> |
