babel icon indicating copy to clipboard operation
babel copied to clipboard

Extract messes up file names with whitespace

Open Dreamsorcerer opened this issue 6 years ago • 3 comments

If a file with whitespace is extracted with the command line tool, the comments include it as 2 different files split on the space, and then sorts them individually. Example output:

#: landing.html:77 web/templates/logged_out/endnote-landing.html:131
#: web/templates/logged_out/wos web/templates/partials/home_page.html:319

Where one of the files is actually "wos landing.html".

Not an urgent issue, I only noticed this while looking at how to handle this edge case for my own code.

Dreamsorcerer avatar Jul 15 '19 13:07 Dreamsorcerer

It's a bad idea to include whitespace in the name. You may have to use escape character for space to create a file on Mac/Linux. e.g.: touch wos\ landing.html. I don't think it's an issue that should be fixed here.

miluchen avatar Aug 21 '19 20:08 miluchen

Or touch 'wos landing.html', or just type it in the GUI as many users do, or in Python with open("wos landing.html"). It's not difficult or even that uncommon for someone to use spaces in a filename.

While I agree that it is recommended not to use spaces in a development project, that doesn't mean this library should break when a developer does a somewhat discouraged, but legitimate thing. If there is a way to escape whitespace in the reference line, then Babel should do so. If not, then Babel should give an error, or just remove the whitespace, so that the name is still close to the original. It definitely shouldn't just output some nonsense invalid references.

Dreamsorcerer avatar Aug 23 '19 19:08 Dreamsorcerer

In my opinion this is a bug in Babel. What Babel should do in this case is to enclose the white space in the filename within First Strong Isolate (U+2068) and Pop Directional Isolate (U+2069) characters, as defined in the portable object template format description (https://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/PO-Files.html).

Dunedan avatar Jul 21 '24 17:07 Dunedan