pybabel extraction mess

Nagy László Zsolt gandalf at shopzeus.com
Tue Nov 3 12:35:43 EST 2015


If I have a large project with multiple directories, then I may want to
assign different translation domains for different subpackages.

Suppose I have this directory structure:

main
   |
   |--- sub1
   |
   |--- sub2
            |
            |---- sub2.1
            |
            |---- sub2.2

There are python source files in subpackages, and also at upper level
packages. Some examples:

main/test1.py
main/sub1/test2.py
main/sub2/test3.py
main/sub2/sub2.1/test4.py
main/sub2/sub2.2/test5.py
....


I cannot find out how to run pybabel so that messages from different
subdirectories gets extracted into different catalog files. The main
problem is that pybabel expects a directory. Let's say that I want to
have a different domain for main/sub2/sub2.1, and another domain for
everything else.

I can extract messages from main/sub/sub2.1 with "pybabel extract
main/sub/sub2.1", but I'm not able to extract all the others into a
different pot file. Simply because "pybabel extract main" will extract
all messages from main/sub2/sub2.1 again. There is no way to extract
from a list of files. Just from directories. It does not seem possible
to specify disjunct sets of files for message catalogs.

For a small project, this is not a problem. If I have at least one file
at the main level, then all other files MUST be bound to the same
domain, because the top level file can only be extracted by giving the
top directory to pybabel, but that will also extract everything else
from the whole project.

I would really like to divide messages into different domains. But how?
Is there a way to run pybabel programatically on a list of source files?

Thanks,

   Laszlo





More information about the Python-list mailing list