Generate Translation Files

A snippet showing how to generate translation files with makemessages.


# From the project root (where manage.py lives)

# Create locale dir and extract strings for French (fr) and Spanish (es)
django-admin makemessages -l fr
django-admin makemessages -l es

# Or extract all locales based on existing PO files
django-admin makemessages -a

# Include JavaScript strings (scan .js files)
django-admin makemessages -d djangojs -l fr
      
Explanation:
  • Ensure LOCALE_PATHS is set or use app-level locale/ directories.
  • .po files are created under locale//LC_MESSAGES/ with extracted msgids.
Never miss a story on Django.wiki

Subscribe for fresh tutorials, snippets, and updates.

By subscribing you agree to our Privacy Policy.