Django

Code

Changeset 756

Show
Ignore:
Timestamp:
10/01/05 07:56:12 (3 years ago)
Author:
hugo
Message:

i18n: updated the documentation to list ngettext

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/i18n/docs/translation.txt

    r751 r756  
    5050 
    5151The other two helper functions are similar in use:: 
    52  
    5352 
    5453   def hello_world(request, name, site): 
     
    7069is presented to the user. 
    7170 
     71There is a standard problem with translations, that is pluralization of 
     72strings. This is done by the standard helper ngettext like so:: 
     73 
     74    def hello_world(request, count): 
     75        from django.utils.translation import ngettext 
     76        page = ngettext('there is %(count)d object', 'there are %(count)d objects', count) % { 
     77            'count': count, 
     78        } 
     79       return page 
     80 
    7281Using Translations in Templates 
    7382=============================== 
     
    8190   <body> 
    8291   <p>{% i18n _('Hello %(name)s, welcome at %(site)s!') %}</p> 
     92   <p>{% i18n ngettext('There is %(count)d file', 'There are %(count)d files', files|count) %}</p> 
    8393   </body> 
    8494   </html>