Where should the python bubble mapping mapping configuration file be located or named for a stand-alone script?

I'm currently trying to use Babel to create a set of static html pages in different languages โ€‹โ€‹using Jinja2 in a simple script (not as part of a web application).

I am at the point where I need to extract messages for translation, and I know that I have to modify the Babel mapping configuration file to understand Jinja2 templates. Since I am using the command line tool, I assume that I need to create a mapping file.

However, I cannot find in the documentation that the mapping configuration file should be named and where it should be placed. All I know is that I need to place the following:

[jinja2: **/templates/**.html]
encoding = utf-8

to the mapping file as per the Jinja2 documentation. Has anyone done something similar or knew there should be a mapping configuration file? Thank!

+3
source share
2 answers

You can specify the location of the configuration file with -c <filename>.

+3
source

The file location mapping is read from the setup.cfg file (generated by Distutils) in the "extract_messages" section. In this section, you should add a parameter with a name mapping_filethat should point to your mapping file.

Example:

This tells Babel to look for a mapping file with a name message-extraction.iniin the package directory.

[extract_messages]
# some default options
# ..
mapping_file = message-extraction.ini
+2
source

Source: https://habr.com/ru/post/1782064/


All Articles