![]() |
VOOZH | about |
Globalizing Django applications enhances accessibility for users across various languages and regions. Django’s built-in internationalization (i18n) and localization (l10n) tools streamline the adaptation of content, formats, and interfaces for global use.
Internationalization prepares a Django application for use in different languages and regions by separating text that needs translation and supporting various locale formats.
By enabling these features, developers can create a single adaptable codebase ready for localization, reducing overhead and improving scalability.
Localization applies internationalization settings to a specific language or region, making the application match local expectations and cultural standards.
Effective localization delivers a seamless user experience, ensuring that applications feel native to every market they serve.
Django uses the GNU gettext framework to handle translations smoothly and support multiple languages accurately.
This integration ensures consistent, maintainable and scalable translation management within Django projects.
Django’s framework integrates i18n and l10n seamlessly:
Consider a project named 'globalapp' having an app named 'myapp'.
settings.py:Note: django.contrib.internationalization is not needed and causes errors in Django 4.0+.
mkdir locale
After creating this mode, nun Migrations.
For Engish:
python manage.py makemessages -l en
For Spanish:
python manage.py makemessages -l es
This creates locale/en/LC_MESSAGES/django.po and locale/es/LC_MESSAGES/django.po with extracted strings (marked as fuzzy)
#: myapp/models.py:5
msgid "Item Name"
msgstr "Nombre del artículo"#: myapp/models.py:6
msgid "Description"
msgstr "Descripción"#: myapp/models.py:9
msgid "Item"
msgstr "Artículo"#: myapp/models.py:10
msgid "Items"
msgstr "Artículos"#: myapp/templates/home.html:5
msgid "Home Page"
msgstr "Página de inicio"#: myapp/templates/home.html:10
msgid "Today is"
msgstr "Hoy es"#: myapp/templates/home.html:13
#, python-format
msgid "This is a block translation with a variable: %(user_count)s users."
msgstr "Esta es una traducción de bloque con una variable: %(user_count)s usuarios."#: myapp/views.py:8
msgid "Hello, world!"
msgstr "¡Hola, mundo!"#: myapp/views.py:12
#, python-format
msgid "One item available."
msgid_plural "%(count)s items available."
msgstr[0] "Un artículo disponible."
msgstr[1] "%(count)s artículos disponibles."
python manage.py compilemessages
python manage.py runserver
English:
http://127.0.0.1:8000/en/
Spanish:
http://127.0.0.1:8000/es/
Django can automatically adapt date, time, and number formats for different locales.
In settings.py:
USE_L10N = True # Automatic locale-based formatting
Use |unlocalize to display raw formats when needed.
Create a locale-specific formats.py (e.g: locale/es/formats.py):
DATE_FORMAT = 'd/m/Y' # e.g., 28/10/2025
NUMBER_GROUPING = 3
DECIMAL_SEPARATOR = ','
Django prioritizes these locale-specific settings over global settings. DATETIME_FORMAT follows locale precedence to maintain consistency.
Django's built-in i18n and l10n tools can be extended with third-party packages:
Selection depends on project requirements. For example, django-modeltranslation is suitable for simple multilingual models in e-commerce applications.