Posts

Showing posts from April, 2019

Getting started with translating a Django Application

Step by step instructions Step 1: make sure internationalization is turned on Open the settings.py file of your project and look for the USE_I18N setting. The value of this setting should be like this: USE_I18N = True If you can’t find this setting, please create this variable manually. (I18N is a common abbreviation of the word internationalization) Step 2: make the translation function available to settings.py It my come in handy to have translated strings in your settings. For example for error messages or e-mail templates. Add the following to the top of your settings.py: from django.utils.translation import ugettext_lazy as _ You can now use the _() function in settings.py. This function will translate your strings. For example: DEFAULT_ERROR_MESSAGE = _("An error has occurred"). Step 3: define a default language Django uses lowercase ISO 639 codes for languages. For example the English language gets the code en. If you want to differentiate between British or American En…