diff options
Diffstat (limited to 'docs/i18n.txt')
| -rw-r--r-- | docs/i18n.txt | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/docs/i18n.txt b/docs/i18n.txt index e6660f939d..1220ea95b3 100644 --- a/docs/i18n.txt +++ b/docs/i18n.txt @@ -133,8 +133,8 @@ For example, to translate a model's ``help_text``, do the following:: from django.utils.translation import gettext_lazy - class MyThing(meta.Model): - name = meta.CharField(help_text=gettext_lazy('This is the help text')) + class MyThing(models.Model): + name = models.CharField(help_text=gettext_lazy('This is the help text')) In this example, ``gettext_lazy()`` stores a lazy reference to the string -- not the actual translation. The translation itself will be done when the string @@ -145,8 +145,8 @@ If you don't like the verbose name ``gettext_lazy``, you can just alias it as from django.utils.translation import gettext_lazy as _ - class MyThing(meta.Model): - name = meta.CharField(help_text=_('This is the help text')) + class MyThing(models.Model): + name = models.CharField(help_text=_('This is the help text')) Always use lazy translations in `Django models`_. And it's a good idea to add translations for the field names and table names, too. This means writing @@ -155,8 +155,8 @@ class, though:: from django.utils.translation import gettext_lazy as _ - class MyThing(meta.Model): - name = meta.CharField(_('name'), help_text=_('This is the help text')) + class MyThing(models.Model): + name = models.CharField(_('name'), help_text=_('This is the help text')) class Meta: verbose_name = _('my thing') verbose_name_plural = _('mythings') @@ -230,12 +230,17 @@ Each ``RequestContext`` has access to two translation-specific variables: language code and the second is the language name (in that language). * ``LANGUAGE_CODE`` is the current user's preferred language, as a string. Example: ``en-us``. (See "How language preference is discovered", below.) + * ``LANGUAGE_BIDI`` is the current language's direction. If True, it's a + right-to-left language, e.g: Hebrew, Arabic. If False it's a + left-to-right language, e.g: English, French, German etc. + If you don't use the ``RequestContext`` extension, you can get those values with -two tags:: +three tags:: {% get_current_language as LANGUAGE_CODE %} {% get_available_languages as LANGUAGES %} + {% get_current_language_bidi as LANGUAGE_BIDI %} These tags also require a ``{% load i18n %}``. |
