How to translate strings in global templates folder

I had a different templates folder for each app. And then I called makemessages and compilemessages inside, and it worked.

Now I decided to move my HTML files into global templates folder (by global I mean inside the project directory). How to manage translations in that case?

I tried this: switch to the templates directory, then create locale dir, and then call makemessages and compilemessages. But it seems not to work.

Okay, through some reading and experiment I arrived at this question:

Can Django have a global locale directory just as global templates directory?

Oh, no, sorry. I figured it out. Hope this will be helping for others.

Yes, Django can have a global locale directory.

The workflow should be like this:

  1. Create locale directory in the project root.
  2. In the settings.py of your project make a variable LOCALE_PATHS with value [BASE_DIR / "locale"] (for details refer to the documentation Translation | Django documentation | Django). Be very careful with the name of this variable, I had a problem because I wrote it as LOCALE_PATH (without s).
  3. Then you can call makemessages and compilemessages from the project folder.