How does Django decide where to put the output of makemessages?

1.3k views Asked by At

I have a Django app with several local locale folders, stored in the translations folder of the base directory:

  • translations/public/locale/{en,fr}
  • translations/portal/locale/{en,fr}
  • translations/terminology/locale/{en,fr}

with corresponding entries in LOCALE_PATHS:

LOCALE_PATHS = (
  os.path.abspath(os.path.join(BASE_DIR, 'translations', 'public', 'locale')),
  os.path.abspath(os.path.join(BASE_DIR, 'translations', 'portal', 'locale')),
  os.path.abspath(os.path.join(BASE_DIR, 'translations', 'terminology', 'locale')),
)

It all works fine, but I don't know how to tell makemessages where to put its output. I don't see any relevant parameters in the source code. My preference would be to put the file somewhere else, like:

% bin/dev/manage.py makemessages -o .../derived_translations

How do I control, or at least determine where the output files are put?

1

There are 1 answers

1
2ps On BEST ANSWER

It says it right in the help for makemessages:

Runs over the entire source tree of the current directory and pulls out all strings marked for translation. It creates (or updates) a message file in the conf/locale (in the django tree) or locale (for projects and applications) directory. You must run this command with one of either the --locale, --exclude, or --all options.

So there you go, they will either be in the conf/locale or app_name/locale directories.

As for customizing the output directory, it does not look like it would be possible without writing a custom version of makemessages.py