From 26bc142f8727e694aae79c690a0549d28b0bb2d9 Mon Sep 17 00:00:00 2001 From: Georg Bauer Date: Sat, 1 Oct 2005 12:56:12 +0000 Subject: [PATCH] i18n: updated the documentation to list ngettext git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@756 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/translation.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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:: {% i18n _('This is the title.') %}

{% i18n _('Hello %(name)s, welcome at %(site)s!') %}

+

{% i18n ngettext('There is %(count)d file', 'There are %(count)d files', files|count) %}