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

Files in directories starting with underscore (_) are not extratcted into .POT #1024

Closed
Porrumentzio opened this issue Aug 26, 2023 · 1 comment

Comments

@Porrumentzio
Copy link

Overview Description

We are using PyBabel for i18n in our software and Jinja2 extension for HTML files. However, files which are located in directories starting with an underscore, e.g. _partials, are not extracted into the .pot file, even if the rest of directories are taken into account.
It happens both with .py files and in .html files (using Jinja2)

This is our Babel config file:

[python: liberaforms/models/**.py]
[python: liberaforms/utils/**.py]
[python: liberaforms/views/**.py]
[jinja2: liberaforms/templates/**.html]
[jinja2: liberaforms/templates/**.js]
[jinja2: assets/inline_help/menu.json]
[jinja2: assets/inline_help/pages/**]
extensions=jinja2.ext.loopcontrols

I also tried pointing to the exact file by including the whole path into the Babel config file.

Is the character _ excluded from **?

Steps to Reproduce

  1. Create a directory starting with an underscore, e.g. _test
  2. Reference the directory in your Babel config file
  3. Run pybabel extract command
  4. Check your updated .pot file: the i18n-ed strings in those directories won't be in the .pot

Actual Results

The files under directories starting with underscore are not included into .pot
If you change the directory name to start with hyphen (-), the file is included.
No matter whether strings are i18n-ed as _("string") or as gettext("string")

Expected Results

If using ** in the Babel config should include all directories (as documentation points out), also directories starting with underscore should be included.

Additional Information

Our code repo: https://gitlab.com/liberaforms/liberaforms/-/tree/develop
Our babel config file: https://gitlab.com/liberaforms/liberaforms/-/blob/develop/babel/messages.cfg
A real example of directory starting with underscore: https://gitlab.com/liberaforms/liberaforms/-/tree/develop/liberaforms/templates/form/_partials

@akx
Copy link
Member

akx commented Oct 1, 2023

See #832 – you should be able to use --ignore-dirs=.* to remove the default _* directory ignore filter.

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

No branches or pull requests

2 participants