Skip to content

symbolic links not followed during extract #1211

Description

@jmoraleda

Problem

Python files that are under symlinked directories are not processed by pybabel.

Expected result

The ** glob pattern in the configuration file instructs pybabel to traverse recursively all sub-directories, including symbolic links.

Am I missing some option in my configuration or command line or is this a bug/missing feature? Thank you.

Background

  • My python project has a complex structure that includes symbolic links to other directories and files.
  • I want to extract a template file for all translation strings in the project including those under directories that are sym-linked.
  • My configuration line includes [python: **.py].
  • I am on Debian Linux.

Activity

  1. jmoraleda commented on Jun 13, 2025

    @jmoraleda
    Author

    I looked at the source code and realized that at the core of the traversal is function extract_from_dir which uses os.walk to traverse the directory. os.walk by default does not traverse symlinks. But it has a parameter followlinks that can be used to instruct it to follow them.

    Since I needed this feature I went ahead and added an optional follow-links parameter in extract_from_dir and frontend. Now passing follow_links=True or --follow-links respectively one is able to tell babel to instruct os.walk to follow symbolic links. If no parameter is passed babel defaults to not follow links, just as before so this new feature should not impact any existing code or workflows.

    I made a PR with the new feature #1212 , including documentation and a unit test.

  2. added theissue type on Dec 30, 2025
  3. added a commit that references this issue on Oct 7, 2026
    c3af7c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions