mquinson / po4a

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

Add custom placeholders for po4a componentes in Weblate #510

Closed rffontenelle closed 1 week ago

rffontenelle commented 2 weeks ago

Both 'po4a' and 'po4a-doc' componentes in Weblate have a lot of formatting syntax, references to options and other texts that could easily be mistranslated and cause the resulting software/documentation to be malformatted or broken. Setting placeholder for such occurrences increases the chances of translation consistency for texts that should not be translated (i.e. should be kept as is in the translation).

If the translator do translate the text that was supposed to be kept as the original in English, a translation check error will be displayed. While it can be dismissed, it will bring to the attention of the translation the fact of a wrong translation of these texts.

I was working on matching potencial targets of a custom placeholder expression, and I came up with the following regexp:

For po4a (Settings > Translation flags):

placeholders:r"\w+(::\w+)+":r"\w+_\w+":r"\w+=\w+":r"\-\w \w+":r" \-?-\w+(\-\w+)?":r"\w+\(\d\)":r"B<\-?\-\w+(\-\w+)?>"

For po4a-doc (Settings > Translation flags):

placeholders:r"(L|B)<[\-_\w\(\)\d\$\[\]\<\>=:;\|\.]*>"

Example of occurrences for each regexp for 'po4a':

\w+(::\w+)+ Pod::Man Locale::Po4a::Man

\w+_\w+ groff_code no_wrap po4a_paths

\w+=\w+ debug=onsgmls mode=after mode=eof

\-\w \w+ -o exclude_include -o doctype

\-?-\w+(\-\w+)? (note the one white-space in the beginning!) --master-charset --localized-charset

\w+\(\d\) man(7) po4a(7) mdoc(7)

B<\-?\-\w+(\-\w+)?> B<--blank> B<--capitalize>

Example of occurrences for each regexp for 'po4a-doc':

(L|B)<[\-_\w\(\)\d\$\[\]\<\>=:;\|\.]*>

Cases:

B<parse_definition_line>
B<paths>
B<--po>
B<po4a->
B<po4a:>
B<po4a-gettextization>
B<PO4A-HEADER:>
B<[po4a_langs]>
B<E<lt>pE<gt>>
L<diff(1)>
L<Locale::Maketext::TPJ13(3pm)|Locale::Maketext::TPJ13(3pm)>
L<Locale::Po4a::AsciiDoc>
L<po4a-build.conf(5)>

po4a-doc might probably have more stuff to match, but this already matches a lot of cases in the docs.

Note: C<> and I<> could have their contents translated, so it would be advised to be make them placeholders.

mquinson commented 1 week ago

Hello,

I have no idea of how to do that. Is there a possibility that I grant you the right to do that for the rest of us? Does weblate allow me to give you the needed privileges over the projects?

Thanks,

rffontenelle commented 1 week ago

I mentioned above in Settings > translation flags above (with link).

But if you prefer have me set it, just go to https://hosted.weblate.org/projects/po4a/, Manage menu item, Users submenu item and add rafaelff as admin

mquinson commented 1 week ago

You're an admin, welcome on board!

rffontenelle commented 1 week ago

I set the custom placeholder expressions and it seems to work. I've spotted some false positives and I've worked around them. Looks good as a starting setting.

mquinson commented 1 week ago

Excellent, thanks. Maybe you can close this bug once everything works as you'd expect?

Thanks again