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

messages not extracted from folders starting with _ or . #53

Closed
mrtopf opened this issue Sep 3, 2013 · 17 comments · Fixed by #832
Closed

messages not extracted from folders starting with _ or . #53

mrtopf opened this issue Sep 3, 2013 · 17 comments · Fixed by #832

Comments

@mrtopf
Copy link

mrtopf commented Sep 3, 2013

Unfortunately I have folders like _m containing templates I would like to be translated. Right now pybabel is ignoring those. I can patch this but was wondering if there is a known reason for this before doing so.

@nandoflorestan
Copy link

+1, pybabel must enter directories starting with underline.
I have forced it to, by adding the directories at the end of the pybabel command.
Even so, if I have a SECOND subdirectory whose name starts with underline, pybabel won't enter that EVEN IF I ADD THE SUBDIRECTORY, too.

nandoflorestan added a commit to nandoflorestan/babel that referenced this issue Oct 13, 2013
Fixes python-babel#53 -- but setup.py configuration support is missing.
@nandoflorestan
Copy link

This patch adds an --ignore-dir-prefix argument to pybabel, so dot and underline aren't hardcoded anymore (they are still the default, though). Hopefully someone will have time to add setup.py configuration support, too.

@chronossc
Copy link

👍 this bug must be solved. Directories with _ is very common in many projects

@slimakovec
Copy link

why isn't the branch still merged? And most importantly - why this issue still exist after 3 years?!

@sils sils added the bug label Oct 16, 2015
@sils
Copy link
Member

sils commented Oct 16, 2015

@slimakovec I can't find a PR associated with that commit apart from it being incomplete as mentioned in the commit message.

Babel was unmaintained for a long time. This time is more or less over and Babel does receive light maintaining from a few people now, we're sorry that so many issues still exist but time is a precious resource. We are happy to accept and review pull requests that solve this issue, maybe based on that existing commit? (In that case please don't forget to attribute at least to the original author.)

@sudheesh001
Copy link
Contributor

@nandoflorestan Your code seems like a great headstart for me as a new contributor to babel to pick and solve. I will give this a shot and try to fix this.

@nandoflorestan
Copy link

@sudheesh001 that's great news, thanks!

@samilyak
Copy link

It's 2018 already and nobody touched this?? :)
This is probably the issue that's every single user of babel faced with immediately after incorporating it in his project.

@akx suggestion here #402 sounds most reasonable to me.

Is anybody up to fix this ridiculous issue already?

Removing subdir.startswith('_') at https://github.com/python-babel/babel/blob/master/babel/messages/extract.py#L142 at least and release it to pip is not a big deal IMO.

@jun66j5
Copy link
Contributor

jun66j5 commented Feb 22, 2018

-1 before fixing #402. I'm using this behavior to avoid traversing directories with many entries (e.g. node_modules to generate css from sass).

andy-pi added a commit to andy-pi/babel that referenced this issue Mar 2, 2018
andy-pi added a commit to andy-pi/babel that referenced this issue Mar 2, 2018
@lohithmadhala
Copy link

Hello, I'm new to open source contribution and I want to try to attempt at solving this issue. Is this issue still open?

@priyansh19
Copy link

Hello, I'm new to open source and I want to contribute to solving this issue of pybabel. Is this issue still open for contribution?

@azzamsa
Copy link

azzamsa commented Feb 25, 2020

Any workaround for now?

It has been 7 years.

My current hack is just to write them manually,

@shub-garg
Copy link

Hello, if this issue is open I would like to work on it.

@pranavkhekare
Copy link

Hello,
Is this issue still open?

@Amaimersion
Copy link

Bump

@Amaimersion
Copy link

Here is simple workaround:

  1. Most probably you don't need to change your babel.cfg

  2. From now run pybabel from Python script, not from Terminal:

# file: pybabel.py

import os

messages_file = "messages.pot"
extract_command = (
    "pybabel extract -F babel.cfg -k lazy_gettext "
    f"-o {messages_file} ."
)

if os.system(extract_command):
    # error
    return
python3 pybabel.py
  1. Add all inputs paths manually instead of dot symbol:
# file: pybabel.py

import os
import glob

messages_file = "messages.pot"
files_to_translate = " ".join([
    # assuming that you run this script from project root
    *glob.glob("src/**/*.py", recursive=True),
    *glob.glob("src/**/*.html", recursive=True)
])
extract_command = (
    "pybabel extract -F babel.cfg -k lazy_gettext "
    f"-o {messages_file} {files_to_translate}"
)

if os.system(extract_command):
    # error
    return
  1. Filter yours files_to_translate as needed

@RomenPoirierTaksev
Copy link

is this still open? It's my first time trying to contribute to an open-source project, but it looks like you guys have already figured it out.

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.