mquinson / po4a

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

Asciidoctor/Callouts issue #351

Closed dbaio closed 2 years ago

dbaio commented 2 years ago

Source file. PO file. po4a version 0.66 and prior releases have the same issue.

po4a-gettextize \
        --format asciidoc \
        --option compat=asciidoctor \
        --option yfm_keys=title,part,description \
        --master "po4a-asciidoctor-callouts.adoc" \
        --master-charset "UTF-8" \
        --copyright-holder "The FreeBSD Project" \
        --package-name "FreeBSD Documentation" \
        --po "po4a-asciidoctor-callouts.po"

-->

#. type: Plain text
#: po4a-asciidoctor-callouts.adoc:16
msgid "<.> Library import <.> URL mapping <.> Response block"
msgstr ""
#. type: Plain text
#: po4a-asciidoctor-callouts.adoc:38
msgid "<.> Callout 1.  <.> Callout 2.  <.> Callout 3."
msgstr ""

It combines all callouts in a single string, making it difficult to translate when you have several callouts together.

I'm reporting this so others can help, but the plan is to dig/debug po4a later.

https://docs.asciidoctor.org/asciidoc/latest/verbatim/callouts/

jnavila commented 2 years ago

Not supported indeed ATM. May be tricky because this is not a standalone list, but a part of another block.

A dumb fix might just work though...

The detection of list bullets is here:

https://github.com/mquinson/po4a/blob/49eaae237a1207b2f137f5c7039289249c9afbb8/lib/Locale/Po4a/AsciiDoc.pm#L846-L847

jnavila commented 2 years ago
diff --git a/lib/Locale/Po4a/AsciiDoc.pm b/lib/Locale/Po4a/AsciiDoc.pm
index 555636dc..afebc29d 100644
--- a/lib/Locale/Po4a/AsciiDoc.pm
+++ b/lib/Locale/Po4a/AsciiDoc.pm
@@ -844,7 +844,7 @@ sub parse {
             $self->pushline(".$t\n");
             @comments = ();
         } elsif ( not defined $self->{verbatim}
-            and ( $line =~ m/^(\s*)((?:[-*o+\.]+|(?:[0-9]+[.\)])|(?:[a-z][.\)])|\([0-9]+\))\s+)(.*)$/ ) )
+            and ( $line =~ m/^(\s*)((?:[-*o+\.]+|(?:[0-9]+[.\)])|(?:[a-z][.\)])|[\(<](?:[0-9]+|\.)[\)>])\s+)(.*)$/ ) )
         {
             my $indent = $1 || "";
             my $bullet = $2;

seems to do it on your sample.

dbaio commented 2 years ago

I've tested this diff in the FreeBSD docs (updating source files and translating), and it worked in all files. It didn't affect any other part.

Strings are all marked as #. type: Plain text.

@jnavila Thanks for taking a look at this and for your time.

jnavila commented 2 years ago

OK. So now, need to design a complete patch with tests. Can I reuse your examples?

dbaio commented 2 years ago

Sure, no problem. It's a mix of examples from Asciidoctor and FreeBSD Docs.