If your application uses models which have parent-child relationships, you may wish to set the
parent option to provide a more appropriate file hierarchy and cascading querysets.
For example, if you have a CMS application with a
Page model which may include
Link objects on each page, you could set your
class LinkOptions(Options): parent = 'page' # name of ForeignKey field to Page # other options here...
Note that the parent model must also be registered with dbgettext.
This has two benefits:
- child objects will only be translated if their parent is (so, for example, links from an unpublished
Pagewill not be included if the parent’s
Optionis set appropriately)
- dbgettext_export will append child output to the parent’s path. For example:
locale/dbgettext/cms/link/link_13/– this provides additional context to the translator
Note that the above example uses a customised
Page to provide nicer a slug-based path (
about_us/contact_us instead of