summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGeorg Bauer <gb@hugo.westfalen.de>2005-10-16 16:15:58 +0000
committerGeorg Bauer <gb@hugo.westfalen.de>2005-10-16 16:15:58 +0000
commit6807c4bd4d209e055bd05e0518a5c86493b16bb3 (patch)
tree0cb0eff4663d875cc7612082a49a3aae53bb4572 /docs
parenta6a0d1ddcc058f1261b191a5972474c64aaf462e (diff)
i18n: updated translation documentation for gettext_lazy
git-svn-id: http://code.djangoproject.com/svn/django/branches/i18n@885 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/translation.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/docs/translation.txt b/docs/translation.txt
index 37d2bc2385..0397374568 100644
--- a/docs/translation.txt
+++ b/docs/translation.txt
@@ -68,6 +68,23 @@ 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.
+One special case that isn't available in other gettext usages are lazily
+translated strings. This is needed for stuff that you set up in your django
+model files - those messages are stored internally and translated on access, but
+not translated on storage (as that would only take the default language into account).
+To translate a model helptext, do the following::
+
+ from django.utils.translation import gettext_lazy
+
+ class Mything(meta.Model):
+
+ name = meta.CharField('Name', help_text=gettext_lazy('This is the help text'))
+ ...
+
+This way only a lazy reference is stored for the string, not the actual translation.
+The translation itself will be done when the string is used in a string context, like
+template rendering in the admin.
+
There is a standard problem with translations, that is pluralization of
strings. This is done by the standard helper ngettext like so::