diff --git a/docs/messages.rst b/docs/messages.rst index 3ab62489a..73a1f8c2a 100644 --- a/docs/messages.rst +++ b/docs/messages.rst @@ -120,8 +120,9 @@ Genshi markup templates and text templates: .. code-block:: ini - # Extraction from Python source files + # Skip vendored Python files; extract from all other Python files + [ignore: vendor/**.py] [python: **.py] # Extraction from Genshi HTML and text templates @@ -147,6 +148,13 @@ two subsequent asterisk characters (``**``) can be used to make the wildcard match any directory level, so the pattern ``**.txt`` matches any file with the extension ``.txt`` in any directory. +When extracting from a directory, Babel matches each file's path relative to +that directory and uses the first matching method. For example, with +``pybabel extract -F babel.cfg -o messages.pot src``, the path matched for +``src/vendor/example.py`` is ``vendor/example.py``. Put the ``ignore`` mapping +before ``[python: **.py]`` as shown above; otherwise the Python extractor will +process the vendored file too. + Babel supports two configuration file formats: INI and TOML. INI Configuration Format @@ -177,7 +185,11 @@ The same configuration examples shown above can be written in TOML format: .. code-block:: toml - # Extraction from Python source files + # Skip vendored Python files; extract from all other Python files + [[mappings]] + method = "ignore" + pattern = "vendor/**.py" + [[mappings]] method = "python" pattern = "**.py"