1. Florent Cayré
  2. i18nfield

Commits

Florent Cayré  committed fe133be

fix reST format in README

  • Participants
  • Parent commits f0aeead
  • Branches default

Comments (0)

Files changed (1)

File README

View file
 To achieve this for your particular entity type, you have to:
 
 * add an 'i18nfield_of' relation definition, linking from the 'I18nField'
-entity type to your translatable entity type(s)
+  entity type to your translatable entity type(s)
 
 * add a 'ref_lang' relation definition, linking from your entity types
-to the 'Language' entity type
+  to the 'Language' entity type
 
 * make your business entity type inherit the 'TranslatableEntityMixin' and
-list its translatable fields in its 'i18nfields' attribute
+  list its translatable fields in its 'i18nfields' attribute
 
 * create a simple adapter that inherits '_TranslatableEntityAdapter' and is
-selectable for your translatable entity types
+  selectable for your translatable entity types
 
 That's all for the code part. Just add at least one Language instance in your
 database and link your translatable entities to their reference language.
 
 .. sourcecode:: python
 
- from cubicweb.selectors import is_instance
- 
- from cubes.card.entities import Card as OrigCard
- from cubes.i18nfield.entities import (TranslatableEntityMixin,
-                                       _TranslatableEntityAdapter)
- 
- 
- class Card(TranslatableEntityMixin, OrigCard):
-     i18nfields = (u'title', u'synopsis', u'content')
- 
-     def dc_title(self):
-         return self.printable_value('title', format='text/plain')
- 
- 
- class MyTranslatableEntityAdapter(_TranslatableEntityAdapter):
-     __select__ = _TranslatableEntityAdapter.__select__ & is_instance('Card')
+   from cubicweb.selectors import is_instance
+   
+   from cubes.card.entities import Card as OrigCard
+   from cubes.i18nfield.entities import (TranslatableEntityMixin,
+                                         _TranslatableEntityAdapter)
+   
+   
+   class Card(TranslatableEntityMixin, OrigCard):
+       i18nfields = (u'title', u'synopsis', u'content')
+   
+       def dc_title(self):
+           return self.printable_value('title', format='text/plain')
+   
+   
+   class MyTranslatableEntityAdapter(_TranslatableEntityAdapter):
+       __select__ = _TranslatableEntityAdapter.__select__ & is_instance('Card')