Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Translator is an app for collecting translations for specified keys in django admin.

Project description

Translator is an app for collecting translations for specified keys in django admin.

Quick start

  1. Install django-translator: pip install django-translator

  2. Add “translator, taggit, modeltranslation” to your INSTALLED_APPS setting. Please note that modeltranslation needs to be before django.contrib.admin:

  3. You have to set the migrations folder for the translator, because we have to add migrations for the set languages. Add the following to your settings file:

        'translator': 'my_project.translator_migrations',
  4. Create a translator_migrations python package in your project folder (where your usually is).

  5. Run python makemigrations translator to create the translator models based on the languages you specified in your settings file.

  6. Run python migrate to migrate the translator models to your database.

  7. If you intend to use it in the templates, add ‘translator.context_processors.translator’ to TEMPLATE_CONTEXT_PROCESSORS

  8. Create translation keys in your templates and models.



    {{ translator.a_key }}

    from translator.util import translator_lazy as _
    class Product(models.Model):
        name = models.TextField(verbose_name=_(u"a_key"))
  9. Visit the templates. The keys get collected lazy.

  10. Translate the keys in the admin.

  11. You can disable the translator by setting DJANGO_TRANSLATOR_ENABLED to False.

  12. Use a double underscore in your translation keys to make use of the filter in the admin (e.g. “header__title” creates a filter called “header”). If you need another separator, set it as DJANGO_TRANSLATOR_CATEGORY_SEPARATOR in your setting file.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-translator, version 1.0.13
Filename, size File type Python version Upload date Hashes
Filename, size django-translator-1.0.13.tar.gz (9.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page