Re: Localized English words ('See', 'see', 'Short Table of Contents') (TeX output)

Patrice Dumas <[email protected]> Thu, 5 Mar 2026 00:40:43 +0100
Newsgroups gmane.comp.tex.texinfo.general
Message-ID <[email protected]>
--aRx7S+UI/6vqdaKe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Mar 03, 2026 at 10:22:54PM -0300, Jamenson Espindula wrote:
> 
> Please, as an example, could you write here the _exact commands_ I
> should emit to get 'See' translated as 'Veja-se'?

I attached an init file that can be used to set the translations.
texi2any should be called like that to use the init file:

 texi2any --html --init-file t2a_modify_translations.pm my_manual.texi

The strings to translate are commented-out, like
       # 'Next' => {'NodeNext direction string' => ''},
You should replace the last string by the translation, as shown for
the following example:
        'See {reference_name}' => {'' => 'Veja-se {reference_name}'},

I collected the strings to translate by converting some manual.  But the
string for your manual may be different.  To get the strings to be
translated, you can use the same init file and uncomment the 9 lines
after the line:
  # uncomment next lines to have the strings to translate being printed

Then the non translated string that are output by texi2any will be
output on the standard error, with the same format as the commented-out
strings as explained above.

-- 
Pat

--aRx7S+UI/6vqdaKe
Content-Type: text/x-perl; charset=us-ascii
Content-Disposition: attachment; filename="t2a_modify_translations.pm"


use strict;
use warnings;

my %translations = (
  'pt' => {
       # 'error@arrow{}' => {'' => ''},
       # 'Next' => {'NodeNext direction string' => ''},
       # ' &nbsp; ' => {'' => ''},
       # 'Table of contents' => {'Contents direction description' => ''},
       # 'Contents' => {'Contents direction string' => ''},
       # 'Index' => {'Index direction description' => ''},
       # 'Index' => {'Index direction string' => ''},
       # ' ? ' => {'' => ''},
       # '{number} {section_title}' => {'' => ''},
       # 'Appendix {number} {section_title}' => {'' => ''},
       # 'Short Table of Contents' => {'shortcontents section heading' => ''},
       # 'Table of Contents' => {'contents section heading' => ''},
       # '{element_text} ({title})' => {'' => ''},
       # 'Previous' => {'NodePrev direction string' => ''},
       # 'Up' => {'NodeUp direction string' => ''},
       # 'see {reference_name}' => {'' => ''},
        'See {reference_name}' => {'' => 'Veja-se {reference_name}'},
       # '{reference} in @cite{{book}}' => {'' => ''},
       # 'see @cite{{book_reference}}' => {'' => ''},
       # 'see {reference} in @cite{{book}}' => {'' => ''},
       # '{reference_name}' => {'' => ''},
       # 'See @cite{{book_reference}}' => {'' => ''},
       # 'See {reference} in @cite{{book}}' => {'' => ''},
       # 'Footnotes' => {'footnotes section heading' => ''},
       # '{explained_string} ({explanation})' => {'' => ''},
       # '@b{{quotation_arg}:} ' => {'' => ''},
       # '@center --- @emph{{author}}' => {'' => ''},
       # '{category}: ' => {'' => ''},
       # '{category} of @code{{class}}: ' => {'' => ''},
       # '@cite{{book_reference}}' => {'' => ''},
       # 'Jump to' => {'' => ''},
       # 'The node you are looking for is at {href}.' => {'' => ''},
   },
);

my $seen_translated = {};
my $translated_lang = 'pt';

sub my_format_translate_message($$$;$) {   
  my ($converter, $string, $lang, $translation_context) = @_;

  $translation_context = '' if (!defined($translation_context));

  # uncomment next lines to have the strings to translate being printed
  #if (!exists($seen_translated->{"$string-$translation_context"})) {
  #  if (!exists($translations{$translated_lang})
  #      or !exists($translations{$translated_lang}->{$string})
  #      or !exists($translations{$translated_lang}->{$string}
  #                                        ->{$translation_context})) {
  #    print STDERR "       # '$string' => {'$translation_context' => ''},\n";
  #  }
  #  $seen_translated->{"$string-$translation_context"} = 1;
  #}

  return $string if (!defined($lang) or $lang eq '');
  if (exists($translations{$lang})
      and exists($translations{$lang}->{$string})
      and exists($translations{$lang}->{$string}->{$translation_context})) {
    my $translation = $translations{$lang}->{$string}->{$translation_context};
    return $translation;
  }
  return undef;
}

texinfo_register_formatting_function('format_translate_message',
                                          \&my_format_translate_message);

sub my_reset_seen_translated {
  $seen_translated = {};

  return 0;
}

texinfo_register_handler('setup', \&my_reset_seen_translated);

1;

--aRx7S+UI/6vqdaKe--