Skip to content

Avoid generating translation terms for terms already available in Django framework

deby edited this page Oct 18, 2018 · 4 revisions

↑ Parent: Python Utils

← Previous: Validators

Every time you add a new term to translate, check if it's not already provided by the Django Framework, to avoid adding more work to our translators when the terms don't need to be transated again.

If it is, add it in or create a file ${PROJECT}/django_translated.py like so:

from django.utils.translation import ugettext_lazy as _
from magi.django_translated import t

t.update({
    'Japanese': _('Japanese'),
})

When you want to use the term, do:

from .django_translated import t

print t['Japanese']

When generating the terms, make sure you don't include the terms in this file:

python manage.py makemessages ... --ignore=${PROJECT}/django_translated.py

See ⎡Translations⎦.

I. Introduction

II. Tutorials

  1. Collections
    1. MagiModel
    2. MagiCollection
    3. MagiForm
    4. MagiFiltersForm
    5. MagiFields
  2. Single pages
  3. Configuring the navbar

III. References

IV. Utils

V. Advanced tutorials

VI. More

Clone this wiki locally