Ticket #12193: 12193.diff

File 12193.diff, 1.8 KB (added by Ramiro Morales, 15 years ago)

Patch updated to post i18n docs refactor.

  • docs/topics/i18n/internationalization.txt

    diff --git a/docs/topics/i18n/internationalization.txt b/docs/topics/i18n/internationalization.txt
    a b  
    258258            verbose_name = _('my thing')
    259259            verbose_name_plural = _('mythings')
    260260
     261Notes on model classes translation
     262~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     263
     264Your model classes may not only contain normal fields: you may have relations
     265(with a ``ForeignKey`` field) or additional model methods you may use for
     266columns in the Django admin site.
     267
     268If you have models with foreign keys and you use the Django admin site, you can
     269provide translations for the relation itself by using the ``verbose_name``
     270parameter on the ``ForeignKey`` object::
     271
     272    class MyThing(models.Model):
     273        kind = models.ForeignKey(ThingKind, related_name='kinds',
     274                                 verbose_name=_('kind'))
     275
     276As you would do for the ``verbose_name`` and ``verbose_name_plural`` settings of
     277a model Meta class, you should provide a lowercase verbose name text for the
     278relation as Django will automatically titlecase it when required.
     279
     280For model methods, you can provide translations to Django and the admin site
     281with the ``short_description`` parameter set on the corresponding method::
     282
     283    class MyThing(models.Model):
     284        kind = models.ForeignKey(ThingKind, related_name='kinds',
     285                                 verbose_name=_('kind'))
     286
     287        def is_mouse(self):
     288            return self.kind.type == MOUSE_TYPE
     289        is_mouse.short_description = _('Is it a mouse?')
     290
     291As always with model classes translations, don't forget to use the lazy
     292translation method!
     293
    261294Working with lazy translation objects
    262295-------------------------------------
    263296
Back to Top