Django

Code

Changeset 885

Show
Ignore:
Timestamp:
10/16/05 11:15:58 (3 years ago)
Author:
hugo
Message:

i18n: updated translation documentation for gettext_lazy

Files:

Legend:

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

    r848 r885  
    6868should be translated at the last possible point in time, when the string 
    6969is presented to the user. 
     70 
     71One special case that isn't available in other gettext usages are lazily 
     72translated strings. This is needed for stuff that you set up in your django 
     73model files - those messages are stored internally and translated on access, but 
     74not translated on storage (as that would only take the default language into account). 
     75To translate a model helptext, do the following:: 
     76 
     77    from django.utils.translation import gettext_lazy 
     78 
     79    class Mything(meta.Model): 
     80 
     81        name = meta.CharField('Name', help_text=gettext_lazy('This is the help text')) 
     82        ... 
     83 
     84This way only a lazy reference is stored for the string, not the actual translation. 
     85The translation itself will be done when the string is used in a string context, like 
     86template rendering in the admin. 
    7087 
    7188There is a standard problem with translations, that is pluralization of