python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.33k stars 444 forks source link

Excluding files from message extraction is under-documented (ignore) #124

Open rbu opened 9 years ago

rbu commented 9 years ago

I was trying to exclude a folder from message extraction through an ignore rule in the mapping file, and ended up having to read the source code to find out how to do it. Some of the questions that are not answered in the documentation are:

rbu commented 9 years ago

So, after quite some debugging, a rule to exclude "awesomepackage/contrib" must be written as such:

[ignore: contrib/**]

[jinja2: **/templates/**.jinja2]
encoding = utf-8
extensions=jinja2.ext.autoescape,jinja2.ext.with_

[python: **.py]

If the babel.cfg, setup.cfg and "awesomepackage" are within the same directory.

rlam3 commented 8 years ago

Is there a way for us to ignore the entire contrib folder but at the same time have [python: **.py] not look there either? If I have the following tree:

-app --mod1 --static ----js ----css ----node_modules

Id like to ignore the entire node_modules directory and not have

python:**.py check that directory. Is there a way for this?

The closest I got was:

[ignore: static/node_modules/]
[jinja2: templates/**/**.html]
encoding = utf-8
extensions=jinja2.ext.autoescape,jinja2.ext.with_
[python: **.py]

However jinja2 and python are always checking into static even though it is ignored..

You can see this happening in the check_and_call_extract_file method of extract.py

for pattern, method in method_map:
    print (method,filename) <<< this shows you all the things it is trying to match I believe
m-aciek commented 1 year ago

Note: since 2.10 extract accepts --ignore-dirs option with space-separated glob patterns.

I've added a PR #963 with adding them to the documentation.