Author: timo
Date: 2010-12-29 09:39:44 -0600 (Wed, 29 Dec 2010)
New Revision: 15103

Modified:
   django/branches/releases/1.2.X/docs/topics/i18n/internationalization.txt
Log:
[1.2.X] Fixed #12193 - Add details to the i18n documentation for translation of 
model classes (relations and methods). Thanks Maxime Petazzoni and Ramiro for 
work on the patch.

Backport of r15102 from trunk.

Modified: 
django/branches/releases/1.2.X/docs/topics/i18n/internationalization.txt
===================================================================
--- django/branches/releases/1.2.X/docs/topics/i18n/internationalization.txt    
2010-12-29 15:39:12 UTC (rev 15102)
+++ django/branches/releases/1.2.X/docs/topics/i18n/internationalization.txt    
2010-12-29 15:39:44 UTC (rev 15103)
@@ -255,6 +255,39 @@
             verbose_name = _('my thing')
             verbose_name_plural = _('mythings')
 
+Notes on model classes translation
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Your model classes may not only contain normal fields: you may have relations
+(with a ``ForeignKey`` field) or additional model methods you may use for
+columns in the Django admin site.
+
+If you have models with foreign keys and you use the Django admin site, you can
+provide translations for the relation itself by using the ``verbose_name``
+parameter on the ``ForeignKey`` object::
+
+    class MyThing(models.Model):
+        kind = models.ForeignKey(ThingKind, related_name='kinds',
+                                 verbose_name=_('kind'))
+
+As you would do for the ``verbose_name`` and ``verbose_name_plural`` settings 
of
+a model Meta class, you should provide a lowercase verbose name text for the
+relation as Django will automatically titlecase it when required.
+
+For model methods, you can provide translations to Django and the admin site
+with the ``short_description`` parameter set on the corresponding method::
+
+    class MyThing(models.Model):
+        kind = models.ForeignKey(ThingKind, related_name='kinds',
+                                 verbose_name=_('kind'))
+
+        def is_mouse(self):
+            return self.kind.type == MOUSE_TYPE
+        is_mouse.short_description = _('Is it a mouse?')
+
+As always with model classes translations, don't forget to use the lazy
+translation method!
+
 Working with lazy translation objects
 -------------------------------------
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to