Skip to main content

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:

    INSTALLED_APPS = (
    'modeltranslation',
    'django.contrib.admin',
    ...
    'taggit',
    'translator',
    )
    
  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:

    MIGRATION_MODULES = {
        'translator': 'my_project.translator_migrations',
    }
    
  4. Create a translator_migrations python package in your project folder (where your settings.py usually is).

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

  6. Run python manage.py 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

    TEMPLATE_CONTEXT_PROCESSORS = (
           ...
       'translator.context_processors.translator',
    )
    
  8. Create translation keys in your templates and models.

    Examples:

    Template:

    {{ translator.a_key }}
    

    models.py:

    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.

Project details


Release history Release notifications

This version
History Node

1.0.11

History Node

1.0.10

History Node

1.0.9

History Node

1.0.8

History Node

1.0.7

History Node

1.0.6

History Node

1.0.5

History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-translator-1.0.11.tar.gz (4.5 kB) Copy SHA256 hash SHA256 Source None Apr 20, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page