Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19270 closed Cleanup/optimization (needsinfo)

makemessages and compilemessages force the location of PO files

Reported by: julen Owned by: nobody
Component: Core (Management commands) Version:
Severity: Normal Keywords: gettext, l10n, i18n, makemessages, compilemessages
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Django's makemessages and compilemessages management commands currently force applications to put their PO files under <LOCALE_PATH>/<lang_code>/LC_MESSAGES/<domain>.po.

According to the GNU gettext manual, LC_<category> should be used for Message Catalog files, i.e. MO files.

Thus, the cited management commands should at least provide an option to specify the location of PO files. Ideally PO files should be moved off the LC_MESSAGES directory too, as it becomes redundant. LC_MESSAGES directories would only be generated after invoking compilemessages and would only be used at run-time, as a location where compiled files are read from.

Change History (4)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to needsinfo
  • Status changed from new to closed

Indeed, LC_MESSAGES/ isn't designed to hold PO files. But it's been working well until now!

What layout would you suggest? What's the value in making the location configurable?

comment:2 Changed 3 years ago by anonymous

It has been working. Not because it was a good choice, but because nobody really has had any choice but to put their PO files in LC_MESSAGES. They've prioritised a working Django app over fixing this brokenness. I think everyone who first localises a Django app has to work through this confusion, hard to count those lost cycles but they exist.

So 'working' in this sense isn't a good argument, 'work around' is probably a better reason as to why it has been working.

My personal suggestion would be '$project/po/$lang' for the location of the PO files. But I think the reporter is asking for it to be configurable thus:

makemessage --po-location=myapp/po


compilemessages --po-location=myapp/po

The --mo-location could also be configurable making it easier for Django apps that are being distributed being placed in the correct place on the server.

comment:3 Changed 3 years ago by julen

I see this is a matter of source vs build locations. You can opt to do the same in the docs for example and mix the generated HTML files with the source rst files. It'll work, sure, but I doubt you'd want to keep everything mixed (independently of thinking if that was the situation before or not).

My suggestion is:

  • <LOCALE_PATH>/<lang_code>/<domain>.po should be used for source files
  • <LOCALE_PATH>/<lang_code>/LC_MESSAGES/<domain>.mo or <custom_path>/<lang_code>/LC_MESSAGES/<domain>.mo should be used for generated files. The later is useful for apps that want to install files to other directories as part of a setup process when distributing.

comment:4 Changed 3 years ago by anonymous

Any updates or opinions on this?

Note: See TracTickets for help on using tickets.
Back to Top