[Django]-In Django what is i18n?

43👍

It loads translation tags such as {% trans "Text" %} that could be used in template. If you do not use it you can remove {% load i18n %}

When you use trans tag for all text that is not dynamic in templates you can then collect all such strings by running ./manage.py makemessages which creates .po file that would be used for translation.

8👍

{% load i18n %} is needed for internationalization. The purpose of internationalization is to allow a single application to read in multiple languages. In order to do this: you need a few hooks called translation strings. To give your template access to these tags, put {% load i18n %} toward the top of your template..

Refer to this for more info: https://docs.djangoproject.com/en/1.10/topics/i18n/

6👍

In order to make a Django project translatable, you have to add a minimal amount of hooks to your Python code and templates. These hooks are called translation strings. They tell Django: “This text should be translated into the end user’s language, if a translation for this text is available in that language.” It’s your responsibility to mark translatable strings; the system can only translate strings it knows about.

Django’s internationalization hooks are on by default, and that means there’s a bit of i18n-related overhead in certain places of the framework. If you don’t use internationalization, you should take the two seconds to set USE_I18N = False in your settings file. Then Django will make some optimizations so as not to load the internationalization machinery. You’ll probably also want to remove ['django.core.context_processors.i18n'] from your TEMPLATE_CONTEXT_PROCESSORS setting.

For more info: https://docs.djangoproject.com/en/dev/topics/i18n/translation/

Leave a comment