django-dbgettext / docs / dbgettext_export.rst

Simon Meers bcbcdae 

























.. _dbgettext_export:

The ``dbgettext_export`` Management Command
===========================================

To obtain a fresh export of your translatable strings from registered models, simply run::

    python manage.py dbgettext_export

from your project's root directory.

This will create a hierarchy of static files (stored by default in ``<project_root>/locale/dbgettext``, configurable using the ``DBGETTEXT_PATH`` and ``DBGETTEXT_ROOT`` settings) containing the translatable strings. E.g.::

    locale/dbgettext/myapp/mymodel_1/title.py
    locale/dbgettext/myapp/mymodel_1/body.py
    locale/dbgettext/myapp/mymodel_2/title.py
    locale/dbgettext/myapp/mymodel_2/body.py

You can then simply run::

    python manage.py makemessages (...)

as per usual, and these strings will be catalogued for you together with the rest of the translatable strings from your code and templates.

**Note:** the ``<DBGETTEXT_PATH>/<DBGETTEXT_ROOT>`` directory is purged each time ``dbgettext_export`` is run to ensure that old data (e.g. from deleted objects) does not persist in the catalogue.

The paths and names of the static files are intentionally verbose to provide the translator with the context of the string they are translating. You can customise the path using the ``get_path_identifier`` and ``parent`` attributes of the ``Options`` class -- see :doc:`registration`.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.