Backend Development Django Subjective
Oct 03, 2025

Explain Django's internationalization (i18n) and localization (l10n).

Detailed Explanation
Django internationalization and localization:\n\n**Settings:**\n```python\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = True\nLANGUAGE_CODE = 'en-us'\nLANGUAGES = [\n ('en', 'English'),\n ('es', 'Spanish'),\n ('fr', 'French'),\n]\nLOCALE_PATHS = [os.path.join(BASE_DIR, 'locale')]\n```\n\n**Marking Strings for Translation:**\n```python\nfrom django.utils.translation import gettext as _\n\ndef my_view(request):\n message = _('Hello, world!')\n return render(request, 'template.html', {'message': message})\n```\n\n**In Templates:**\n```html\n{% load i18n %}\n{% trans \"Welcome\" %}\n{% blocktrans %}Hello {{ name }}{% endblocktrans %}\n```\n\n**Commands:**\n• django-admin makemessages - Extract translatable strings\n• django-admin compilemessages - Compile translations\n\n**Features:**\n• Plural forms\n• Context-specific translations\n• Lazy translations\n• Time zone support\n• Number/date formatting
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback