Internationalization (i18n)
Snippets for Django internationalization and localization, including translations, gettext usage, and timezone handling. Build apps that work across languages and regions.
Translate Strings in Templates
Use {% trans %} to translate strings in templates.
Block Translation in Templates
Use {% blocktrans %} for dynamic text translations.
Mark Strings for Translation
Use gettext to mark strings in code for translation.
Generate Translation Files
Run makemessages to extract translation strings into .po files.
Compile Translation Files
Run compilemessages to compile .po files into .mo files.
Activate Language in Views
Switch user language dynamically in views.
Language Switcher in Templates
Create a language switcher dropdown in templates.
Set Default Language
Configure the default language in settings.py.
Use LocaleMiddleware
Enable LocaleMiddleware to detect and activate user language automatically.