bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is @emph{See} translatable?


From: Gavin Smith
Subject: Re: Is @emph{See} translatable?
Date: Wed, 27 Sep 2023 19:25:20 +0100

On Tue, Sep 26, 2023 at 09:53:38PM +0100, Gavin Smith wrote:
> On Tue, Sep 26, 2023 at 09:12:23PM +0200, Petr Pisar wrote:
> >     # FIXME: "See" should be translatable, but gettext insists that it's an 
> > identifier.
> >     #. TRANSLATORS: redirect to another index entry
> >     #: tp/Texinfo/Convert/HTML.pm:5675
> >     #, perl-brace-format
> >     msgid "{main_index_entry}, @emph{See} {seenentry}"
> >     msgstr "{main_index_entry}, @emph{Vizte} {seenentry}"
> > 
> > However, GNU gettext reports an error on them:
> > 
> >     $ msgfmt --statistics --check --strict -o texinfo_document.mo cs.po
> >     cs.po:854: a format specification for argument 'See' doesn't exist in 
> > 'msgstr'
> >     cs.po:860: a format specification for argument 'See' doesn't exist in 
> > 'msgstr'
> > 
> > Is the "See" word supposed to be translated? I think it is.
> 
> 
> Yes, "See" should be translated.  It appears to be taking {See} as an
> parameter, just as "{main_index_entry} is.  This is because of the
> "perl-brace-format" directive.

One solution is to change the translated string:

diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index a9366c367c..9ebdb61c10 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -5666,13 +5666,13 @@ sub _convert_printindex_command($$$$)
           if ($in_code) {
             $result_tree
           # TRANSLATORS: redirect to another index entry
-        = $self->gdt('@code{{main_index_entry}}, @emph{See} 
@code{{seenentry}}',
+        = $self->gdt('@code{{main_index_entry}}, @emph{See@:} 
@code{{seenentry}}',
                                         {'main_index_entry' => $entry_ref_tree,
                                          'seenentry' => $referred_tree});
           } else {
             $result_tree
                  # TRANSLATORS: redirect to another index entry
-               = $self->gdt('{main_index_entry}, @emph{See} {seenentry}',
+               = $self->gdt('{main_index_entry}, @emph{See@:} {seenentry}',
                                         {'main_index_entry' => $entry_ref_tree,
                                          'seenentry' => $referred_tree});
           }

By inserting the harmless Texinfo command @: inside the braces, it stops
one of the gettext programs (msgfmt) treating as a placeholder.  I tested
this with fr.po, editing it to look like:

#. TRANSLATORS: redirect to another index entry
#: tp/Texinfo/Convert/HTML.pm:5669
#, perl-brace-format
msgid "@code{{main_index_entry}}, @emph{See@:} @code{{seenentry}}"
msgstr "@code{{main_index_entry}}, @emph{Voir} @code{{seenentry}}"

#. TRANSLATORS: redirect to another index entry
#: tp/Texinfo/Convert/HTML.pm:5675
#, perl-brace-format
msgid "{main_index_entry}, @emph{See@:} {seenentry}"
msgstr "{main_index_entry}, @emph{Voir} {seenentry}"

Note how the {Voir} is ok in msgstr, and doesn't need to be {Voir@:},
although {Voir@:} would be fine too.

(It's slightly tricky to test this: first you have to update the *.po file,
then run "make update-po", then run "make install", then run texi2any.)

That's the best fix I can think of; comments or suggestions welcome.  Here
are some other fixes that I thought were worse:

Another fix might be to remove the @emph completely from the translated
string:

-        = $self->gdt('@code{{main_index_entry}}, @emph{See} @code{{seenentry}}'
+,
+        = $self->gdt('@code{{main_index_entry}}, See @code{{seenentry}
+}',

- but then the "See" text wouldn't be distinguished.

Another fix is to only translate the "See" part of it, so

+        = $self->gdt('See')

and then construct a Texinfo tree with @emph containing the result, along
with the main_index_entry and seenentry content inside @code commands.
This would remove the ability to change the punctuation and word order
for different languages, and would also take more code to do.

A variant of this is to still only translate "See":

+        = $self->gdt('See')

and then to wrap the output with "<em>" and "</em>" strings, not going via
the @emph command at all.

(Using Texinfo commands in translated document strings is of marginal
utility and leads to extra complexity, but would be quite hard to eliminate
completely.)

An alternative approach is to attempt to change the invocation of msgfmt,
perhaps omitting options such as --check.  However, Petr implied in his
message that the TP places restrictions on uploading translation files
if they would lead to such errors:

> For this time, I kept the strings untranslated to be able to upload the
> translation.

so this is a non-starter.  (It's also mysterious to me how to alter the
operation of "make update-po" and whatever po_document/Makefile.in.in
is/does.)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]