Files changed (10)
Empty file added.
+SENTENCE_RE = getattr(settings, 'DBGETTEXT_SENTENCE_RE', re.compile(r'^(.*?\S[\!\?\.])(\s+)(\S+.*)$', re.DOTALL))
+If your application uses models which have parent-child relationships, you may wish to set the ``parent`` :ref:`option <options>` 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 ``Link`` ``Options`` like::
+- child objects will only be translated if their parent is (so, for example, links from an unpublished ``Page`` will not be included if the parent's ``translate-if`` ``Option`` is set appropriately)
+- :doc:`dbgettext_export <dbgettext_export>` will append child output to the parent's path. For example: ``locale/dbgettext/cms/page/about_us/contact_us/link_13/`` instead of ``locale/dbgettext/cms/link/link_13/`` -- this provides additional context to the translator
+django-dbgettext comes with HTML parsing functionality out of the box, allowing translatable strings to be extracted from fields with HTML content. To translate an field containing HTML, simply include its name in the ``parsed_attributes`` dictionary of the registered ``Options`` (see :ref:`options`), (together with ``dbgettext.lexicons.html.lexicon``).
+The ``DBGETTEXT_INLINE_HTML_TAGS`` :ref:`setting <settings>` can be used to define which HTML tags are allowed to appear within translatable strings. E.g.::
+The ``custom_lexicon_rules`` :ref:`option <options>` allow the HTML parsing algorithm to be customised to suit your needs. For example, the following ``gettext.py`` file allows images to appear as moveable placeholders in translatable strings::
+Not using HTML? Want to parse `markdown <http://http://daringfireball.net/projects/markdown/>`_ or something exotic instead? Simply register your own lexicon function like the example provided in ``dbgettext.lexicons.html.py`` (having read ``dbgettext.parser.py`` as well).
+Once you've got something you're happy with, you may wish to consider submitting your file for inclusion in ``dbgettext.lexicons``.
Simply create a ``gettext.py`` file within your application root directory, import the dbgettext ``registry`` object, and register your Models together with their customised ``dbgettext.models.Options``. For example::
* ``DBGETTEXT_PATH``: path (absolute or relative to project root) where :doc:`dbgettext_export <dbgettext_export>` should store its output. Defaults to ``locale``.
* ``DBGETTEXT_ROOT``: name of directory within ``DBGETTEXT_PATH`` (redundancy to provide protection from auto-purging upon export). Defaults to ``dbgettext``.
-* ``DBGETTEXT_INLINE_TAGS``: tuple of tag names allowed to appear inline within strings extracted from ``html_attributes``. Defaults to ``('b','i','u','em','strong',)``.
+* ``DBGETTEXT_INLINE_HTML_TAGS``: tuple of tag names allowed to appear inline within strings parsed with ``dbgettext.lexicons.html``. Defaults to ``('b','i','u','em','strong',)``.
* ``DBGETTEXT_SPLIT_SENTENCES``: split chunks of text into separate sentences for translation where appropriate. Defaults to ``True``.