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

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

Closed mrtopf closed 2 years ago

mrtopf commented 11 years ago

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 commented 11 years ago

+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 commented 11 years ago

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 commented 10 years ago

:+1: this bug must be solved. Directories with _ is very common in many projects

slimakovec commented 9 years ago

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

sils commented 9 years ago

@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 commented 8 years ago

@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 commented 8 years ago

@sudheesh001 that's great news, thanks!

samilyak commented 6 years ago

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 https://github.com/python-babel/babel/issues/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 commented 6 years ago

-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).

lohithmadhala commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

Any workaround for now?

It has been 7 years.

My current hack is just to write them manually,

shub-garg commented 4 years ago

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

pranavkhekare commented 3 years ago

Hello, Is this issue still open?

Amaimersion commented 3 years ago

Bump

Amaimersion commented 3 years ago

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

3) 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

4) Filter yours files_to_translate as needed

RomenPoirierTaksev commented 3 years ago

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.