Opened 66 minutes ago

Last modified 63 minutes ago

#37188 assigned Bug

compilemessages should ignore common environment and dependency directories by default

Reported by: Ayoub Bouaik Owned by: Ayoub Bouaik
Component: Core (Management commands) Version: dev
Severity: Normal Keywords: i18n, compilemessages, venv, node_modules
Cc: Ayoub Bouaik Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The compilemessages management command recursively traverses the entire project tree looking for locale directories. However, it currently lacks default ignore patterns for common python virtual environments (venv, .venv, env, .env) and modern frontend package management directories (node_modules).

Because of this, if a project contains a third-party package inside node_modules or a local virtual environment that includes localized files with formatting quirks (such as a Byte Order Mark), compilemessages attempts to process them, resulting in unexpected execution overhead or critical crashes on files the developer did not write.

Steps to Reproduce
Inside a clean project workspace, run the following commands to simulate a third-party dependency with a BOM-encoded translation file:

  1. Create a dummy package locale path: mkdir -p node_modules/mock-package/locale/en/LC_MESSAGES/
  1. Add a dummy translation file containing a UTF-8 BOM flag: printf '\xEF\xBB\xBF# Dummy translation file\nmsgid ""\nmsgstr ""\n' > node_modules/mock-package/locale/en/LC_MESSAGES/django.po
  1. Attempt to compile messages: python manage.py compilemessages

Expected Behavior
Django should automatically skip top-level dependency and virtual environment folders like node_modules, venv, and .venv unless explicitly instructed otherwise via the -i / --ignore CLI flags.

Actual Output / Traceback
The /home/ayoub/django_test/node_modules/mock-package/locale/en/LC_MESSAGES/django.po file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM.
CommandError: compilemessages generated one or more errors.

Change History (1)

comment:1 by Ayoub Bouaik, 63 minutes ago

Owner: set to Ayoub Bouaik
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top