mquinson / po4a

Maintain the translations of your documentation with ease (PO for anything)
http://po4a.org/
GNU General Public License v2.0
121 stars 58 forks source link

Fenced code blocks not getting translated #376

Closed joelnitta closed 1 year ago

joelnitta commented 1 year ago

I have the following original text file test.md with contents as follows:

This a markdown document

```bash
# a comment to be translated
ls

I generated a PO file with `po4a-updatepo -f text -m test.md -p test.po -o markdown`, then edited it to have these contents:

SOME DESCRIPTIVE TITLE

Copyright (C) YEAR Free Software Foundation, Inc.

This file is distributed under the same license as the PACKAGE package.

FIRST AUTHOR EMAIL@ADDRESS, YEAR.

#

, fuzzy

msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2022-08-08 07:55+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME EMAIL@ADDRESS\n" "Language-Team: LANGUAGE LL@li.org\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n"

. type: Plain text

: test.md:2

, markdown-text

msgid "This a markdown document" msgstr "これはマークダウンです"

. type: Fenced code block (bash)

: test.md:3

, no-wrap

msgid "" "# a comment to be translated\n" "ls\n" msgstr "" "# コメントです\n" "ls\n"


I then translated it with `po4a-translate -f text -m test.md -p test.po -l test-trans.md -k 10`

(aside: I had to set `-k 10`) otherwise I get an error that less than 50% of the file is translated, despite this not being the case. Anyway that's a separate problem...

The output `test-trans.md` looks like this:

これはマークダウンです

bash # a comment to be translated ls



There are two problems:
1. `test-trans.md` does not contain the translated text (the comment) in the code block.
2. The translated code block is all on a single line.

(I tried removing `#, no-wrap` from the comments for translating the code block, but that did not help).

Any help would be greatly appreciated!

po4a version 0.67
running in docker container [`joelnitta/po4a:0.67`](https://github.com/joelnitta/po4a-docker)
mquinson commented 1 year ago

Hello, thanks for reporting.

Where are the test files in the docker image?

joelnitta commented 1 year ago

They are not in the docker image (my intended purpose of that is for general use of po4a), but are very short so I thought you could just copy from the issue.

I have posted them here:

mquinson commented 1 year ago

Hello,

I fail to reproduce your error here. It seems to me that you are missing a -o markdown parameter to your po4a-translate call. That is why your produced document does not follow the markdown correctly.

Could you please tell me if I am right? If you can reproduce the error with -o markdown on translation too, then I would really appreciate if you could come up with a small git repo somewhere containing all files needed to reproduce your bug. Just the user files, not po4a that I obviously have here already.

Thanks in advance, Mt

joelnitta commented 1 year ago

Yes: adding -o markdown to the po4a-translate call fixes it. Thanks so much! I had a feeling I was missing something obvious, but could not spot it.