Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rbu opened this issue Nov 25, 2014 · 3 comments
Open

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

rbu opened this issue Nov 25, 2014 · 3 comments

Comments

@rbu
Copy link

rbu commented Nov 25, 2014

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:

  • How to specify the ignore filter (A: [ignore: something/**.txt])
  • How does Babel evaluate the priority in the mapping? (A: By first match, so ignore rules need to be listed first)
  • What is the path that is matched against? (A: The file path without the package name, see Message extraction mapping does not match against package name #125)
@rbu
Copy link
Author

rbu commented Nov 25, 2014

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
Copy link

rlam3 commented May 3, 2016

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
Copy link
Contributor

m-aciek commented Jan 29, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants