texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Thu, 22 Feb 2024 17:11:55 -0500 (EST)

branch: master
commit e323acfb66bd778610feaf5c83eab9b923de02c8
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Feb 22 22:37:25 2024 +0100

    * tp/Texinfo/Translations.pm (gdt, gdt_string): pass debug_level
    as an argument, change argument order, use customization_information
    as translate_string_method first argument only.  Update callers.
---
 ChangeLog                       |  6 +++
 tp/Texinfo/Convert/Converter.pm |  5 ++-
 tp/Texinfo/Convert/HTML.pm      |  9 ++--
 tp/Texinfo/Convert/Text.pm      |  4 +-
 tp/Texinfo/Convert/Utils.pm     |  4 +-
 tp/Texinfo/ParserNonXS.pm       |  4 +-
 tp/Texinfo/Structuring.pm       | 26 ++++-------
 tp/Texinfo/Translations.pm      | 95 +++++++++++++++++++----------------------
 8 files changed, 74 insertions(+), 79 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 09e76657e6..f9518a0d4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Translations.pm (gdt, gdt_string): pass debug_level
+       as an argument, change argument order, use customization_information
+       as translate_string_method first argument only.  Update callers.
+
 2024-02-22  Patrice Dumas  <pertusus@free.fr>
 
        Update po files.
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 71f7f05412..7665e082bb 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -452,9 +452,10 @@ sub cdt($$;$$)
 {
   my ($self, $string, $replaced_substrings, $translation_context) = @_;
 
-  return Texinfo::Translations::gdt($self, $string,
+  return Texinfo::Translations::gdt($string,
                                     $self->get_conf('documentlanguage'),
                                     $replaced_substrings,
+                                    $self->get_conf('DEBUG'),
                                     $translation_context);
 }
 
@@ -462,7 +463,7 @@ sub cdt_string($$;$$)
 {
   my ($self, $string, $replaced_substrings, $translation_context) = @_;
 
-  return Texinfo::Translations::gdt_string($self, $string,
+  return Texinfo::Translations::gdt_string($string,
                                     $self->get_conf('documentlanguage'),
                                     $replaced_substrings,
                                     $translation_context);
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 5c0d976f79..acf8ceff4d 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2907,10 +2907,11 @@ sub cdt($$;$$)
 {
   my ($self, $string, $replaced_substrings, $translation_context) = @_;
 
-  return Texinfo::Translations::gdt($self, $string,
+  return Texinfo::Translations::gdt($string,
                                     $self->get_conf('documentlanguage'),
                                     $replaced_substrings,
-                                    $translation_context,
+                                    $self->get_conf('DEBUG'),
+                                    $translation_context, $self,
                                     \&html_translate_string);
 }
 
@@ -2918,10 +2919,10 @@ sub cdt_string($$;$$)
 {
   my ($self, $string, $replaced_substrings, $translation_context) = @_;
 
-  return Texinfo::Translations::gdt_string($self, $string,
+  return Texinfo::Translations::gdt_string($string,
                                     $self->get_conf('documentlanguage'),
                                     $replaced_substrings,
-                                    $translation_context,
+                                    $translation_context, $self,
                                     \&html_translate_string);
 }
 
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index b620077696..c5cafaeed6 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -507,9 +507,9 @@ sub _convert($$)
       } else {
         # if there is no converter, we use the documentlanguage available
         # in the tree.
-        $tree = Texinfo::Translations::gdt(undef, $element->{'text'},
+        $tree = Texinfo::Translations::gdt($element->{'text'},
                              $element->{'extra'}->{'documentlanguage'},
-                             undef, $translation_context);
+                             undef, undef, $translation_context);
       }
       $result = _convert($options, $tree);
     } else {
diff --git a/tp/Texinfo/Convert/Utils.pm b/tp/Texinfo/Convert/Utils.pm
index f4e122fc67..bae8e916e7 100644
--- a/tp/Texinfo/Convert/Utils.pm
+++ b/tp/Texinfo/Convert/Utils.pm
@@ -175,7 +175,7 @@ sub definition_category_tree($$)
       # in descriptions of object-oriented programming methods or operations.
       return $self->cdt('{category} on @code{{class}}', $substrings);
     } else {
-      return Texinfo::Translations::gdt(undef, '{category} on @code{{class}}',
+      return Texinfo::Translations::gdt('{category} on @code{{class}}',
                                  $current->{'extra'}->{'documentlanguage'},
                                  $substrings);
       #my $result = {};
@@ -195,7 +195,7 @@ sub definition_category_tree($$)
       # or instance variable.
       return $self->cdt('{category} of @code{{class}}', $substrings);
     } else {
-      return Texinfo::Translations::gdt(undef, '{category} of @code{{class}}',
+      return Texinfo::Translations::gdt('{category} of @code{{class}}',
                                  $current->{'extra'}->{'documentlanguage'},
                                  $substrings);
       #my $result = {};
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index ec570f5f9a..62c4a0606f 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -3939,7 +3939,7 @@ sub _end_line_def_line($$$)
     if (defined($index_entry)) {
       if ($class_element) {
         # Delay getting the text until Texinfo::Indices
-        # in order to avoid using gdt.
+        # in order to avoid calling gdt.
         # We need to store the language as well in case there are multiple
         # languages in the document.
         if ($command_index{$def_command} eq 'fn'
@@ -7148,7 +7148,7 @@ sub _process_remaining_on_line($$$$)
                sprintf(__("undefined flag: %s"), $value), $source_info);
 
             # caller should expand something along
-            # gdt($self, '@{No value for `{value}\'@}',
+            # cdt($self, '@{No value for `{value}\'@}',
             #                            {'value' => ...});
             my $new_element = _new_value_element($command, $value, $current,
                                                  $spaces_element);
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index a6e9e3c7ef..368ecaeae5 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -1480,10 +1480,10 @@ sub new_complete_node_menu
             = Texinfo::Common::copy_contentsNonXS(
                                 $associated_part->{'args'}->[0]);
           my $part_title
-           = Texinfo::Translations::gdt($customization_information,
-                                        'Part: {part_title}',
+           = Texinfo::Translations::gdt('Part: {part_title}',
                     $customization_information->get_conf('documentlanguage'),
-                                     {'part_title' => $part_title_copy});
+                                     {'part_title' => $part_title_copy},
+                              $customization_information->get_conf('DEBUG'));
           _insert_menu_comment_content($new_menu->{'contents'}, $content_index,
                                        $part_title, ($content_index == 0));
           $content_index++;
@@ -1492,9 +1492,9 @@ sub new_complete_node_menu
         if (!$in_appendix
             and $appendix_commands{$child_section->{'cmdname'}}) {
           my $appendix_title
-             = Texinfo::Translations::gdt($customization_information,
-                                          'Appendices',
-                   $customization_information->get_conf('documentlanguage'));
+             = Texinfo::Translations::gdt('Appendices',
+                   $customization_information->get_conf('documentlanguage'),
+                      undef, $customization_information->get_conf('DEBUG'));
           _insert_menu_comment_content($new_menu->{'contents'}, $content_index,
                                        $appendix_title,
                                        ($content_index == 0 or $part_added));
@@ -1542,9 +1542,9 @@ sub new_master_menu($$$;$)
     # detailed menu section with the node section name
     my $first_preformatted = 
$master_menu->{'contents'}->[0]->{'contents'}->[0];
     my $master_menu_title
-           = Texinfo::Translations::gdt($customization_information,
-                                        ' --- The Detailed Node Listing ---',
-                    $customization_information->get_conf('documentlanguage'));
+           = Texinfo::Translations::gdt(' --- The Detailed Node Listing ---',
+                    $customization_information->get_conf('documentlanguage'),
+                  undef, $customization_information->get_conf('DEBUG'));
     my @master_menu_title_contents;
     foreach my $content (@{$master_menu_title->{'contents'}}, {'text' => 
"\n"}) {
       $content->{'parent'} = $first_preformatted;
@@ -1660,14 +1660,6 @@ sub _print_down_menus($$;$)
   return @master_menu_contents;
 }
 
-if (0) {
-  # it is needed to mark the translation as gdt is called like
-  # gdt($customization_information, ' --- The Detailed Node Listing ---', ...)
-  # and not like gdt(' --- The Detailed Node Listing ---', ...)
-  gdt(' --- The Detailed Node Listing ---');
-}
-
-
 # Return a list of output units.  Each output unit starts with a @node as its
 # first content (except possibly the first one).  It is important that this
 # function reassociates all the root commands such that the result does not
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index e0eeeb303e..5651797494 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -228,10 +228,11 @@ sub translate_string($$;$)
 # of translate_string.  $TRANSLATED_STRING_METHOD takes
 # $CUSTOMIZATION_INFORMATION as first argument in addition to other
 # translate_string arguments.
-sub gdt($$;$$$$)
+sub gdt($;$$$$$$)
 {
-  my ($customization_information, $string, $lang, $replaced_substrings,
-      $translation_context, $translate_string_method) = @_;
+  my ($string, $lang, $replaced_substrings, $debug_level,
+      $translation_context, $customization_information,
+      $translate_string_method) = @_;
 
   my $translated_string;
   if ($translate_string_method) {
@@ -241,11 +242,6 @@ sub gdt($$;$$$$)
     $translated_string = translate_string($string, $lang, 
$translation_context);
   }
 
-  my $debug_level;
-  if ($customization_information) {
-    $debug_level = $customization_information->get_conf('DEBUG');
-  }
-
   my $result_tree
     = _replace_convert_substrings($translated_string, $replaced_substrings,
                                   $debug_level);
@@ -257,10 +253,10 @@ sub gdt($$;$$$$)
 # Get document translation - handle translations of in-document strings.
 # In general for already converted strings that do not need to go through
 # a Texinfo tree.
-sub gdt_string($$;$$$$)
+sub gdt_string($;$$$$$)
 {
-  my ($customization_information, $string, $lang, $replaced_substrings,
-      $translation_context, $translate_string_method) = @_;
+  my ($string, $lang, $replaced_substrings, $translation_context,
+      $customization_information, $translate_string_method) = @_;
 
   my $translated_string;
   if ($translate_string_method) {
@@ -384,25 +380,12 @@ sub _substitute($$) {
 
 # Same as gdt but with mandatory translation context, used for marking
 # of strings with translation contexts
-sub pgdt($$$;$$)
+sub pgdt($$;$$$)
 {
-  my ($customization_information, $translation_context, $string,
-      $lang, $replaced_substrings) = @_;
-  return gdt($customization_information, $string, $lang,
-             $replaced_substrings, $translation_context);
-}
-
-if (0) {
-  # it is needed to mark the translation as gdt is called like
-  # gdt($customization_information, '....')
-  # and not like gdt('....')
-  # TRANSLATORS: association of a method or operation name with a class
-  # in descriptions of object-oriented programming methods or operations.
-  gdt('{name} on {class}', undef, undef);
-  # TRANSLATORS: association of a variable or instance variable with
-  # a class in descriptions of object-oriented programming variables or
-  # instance variable.
-  gdt('{name} of {class}', undef, undef);
+  my ($translation_context, $string,
+      $lang, $replaced_substrings, $debug_level) = @_;
+  return gdt($string, $lang, $replaced_substrings, $debug_level,
+             $translation_context, $debug_level);
 }
 
 # For some @def* commands, we delay storing the contents of the
@@ -413,6 +396,11 @@ sub complete_indices($$)
   my $customization_information = shift;
   my $index_names = shift;
 
+  my $debug_level;
+  if ($customization_information) {
+    $debug_level = $customization_information->get_conf('DEBUG');
+  }
+
   foreach my $index_name (sort(keys(%{$index_names}))) {
     next if (not defined($index_names->{$index_name}->{'index_entries'}));
     foreach my $entry (@{$index_names->{$index_name}->{'index_entries'}}) {
@@ -453,18 +441,23 @@ sub complete_indices($$)
               or $def_command eq 'deftypeop'
               or $def_command eq 'defmethod'
               or $def_command eq 'deftypemethod') {
-            $index_entry = gdt($customization_information, '{name} on {class}',
-                               $entry_language,
-                               {'name' => $name_copy, 'class' => $class_copy});
+  # TRANSLATORS: association of a method or operation name with a class
+  # in descriptions of object-oriented programming methods or operations.
+            $index_entry = gdt('{name} on {class}', $entry_language,
+                               {'name' => $name_copy, 'class' => $class_copy},
+                               $debug_level);
             $text_element = {'text' => ' on ',
                              'parent' => $index_entry_normalized};
           } elsif ($def_command eq 'defcv'
                    or $def_command eq 'defivar'
                    or $def_command eq 'deftypeivar'
                    or $def_command eq 'deftypecv') {
-            $index_entry = gdt($customization_information, '{name} of {class}',
-                               $entry_language,
-                               {'name' => $name_copy, 'class' => $class_copy});
+  # TRANSLATORS: association of a variable or instance variable with
+  # a class in descriptions of object-oriented programming variables or
+  # instance variable.
+            $index_entry = gdt('{name} of {class}', $entry_language,
+                               {'name' => $name_copy, 'class' => $class_copy},
+                               $debug_level);
             $text_element = {'text' => ' of ',
                              'parent' => $index_entry_normalized};
           }
@@ -501,10 +494,11 @@ Texinfo::Translations - Translations of output documents 
strings for Texinfo mod
 
   Texinfo::Translations::configure('LocaleData');
 
-  my $tree_translated = $converter->gdt('See {reference} in @cite{{book}}',
-                         $converter->get_conf('documentlanguage'),
-                       {'reference' => $tree_reference,
-                        'book'  => {'text' => $book_name}});
+  my $tree_translated
+    = Texinfo::Translations::gdt('See {reference} in @cite{{book}}',
+                           $converter->get_conf('documentlanguage'),
+                          {'reference' => $tree_reference,
+                           'book'  => {'text' => $book_name}});
 
 
 =head1 NOTES
@@ -546,9 +540,9 @@ but returns a simple string, for already converted strings.
 
 =over
 
-=item $tree = $object->gdt($string, $lang, $replaced_substrings, 
$translation_context, $translate_string_method)
+=item $tree = gdt($string, $lang, $replaced_substrings, $translation_context, 
$debug_level, $object, $translate_string_method)
 
-=item $string = $object->gdt_string($string, $lang, $replaced_substrings, 
$translation_context, $translate_string_method)
+=item $string = gdt_string($string, $lang, $replaced_substrings, 
$translation_context, $object, $translate_string_method)
 
 X<C<gdt>> X<C<gdt_string>>
 
@@ -568,9 +562,9 @@ For C<gdt>, the value is a Texinfo tree that is substituted 
in the
 resulting texinfo tree. For C<gdt_string>, the value is a string that
 is replaced in the resulting string.
 
-The I<$object> is typically a converter, but can be any object that implements
-C<get_conf>, or undefined (C<undef>).  If not undefined, the information in the
-I<$object> is used to get some customization information.
+I<$debug_level> is an optional debugging level supplied to gdt, similar to the
+C<DEBUG> customization variable.  If set, the debug level minus one is passed 
to
+the parser.
 
 The I<$translation_context> is optional.  If not C<undef> this is a translation
 context string for I<$string>.  It is the first argument of C<pgettext>
@@ -578,7 +572,8 @@ in the C API of Gettext.
 
 The I<$translate_string_method> is optional.  If not undef it should be a
 reference on a function that is called instead of C<translate_string>.  It
-allows to customize string translation.
+allows to customize string translation.  The I<$object> is passed as first
+argument of the <$translate_string_method>.
 
 For example, in the following call, the string
 C<See {reference} in @cite{{book}}> is translated, then
@@ -586,15 +581,15 @@ parsed as a Texinfo string, with I<{reference}> 
substituted by
 I<$tree_reference> in the resulting tree, and I<{book}>
 replaced by the associated texinfo tree text element:
 
-  $tree = $converter->gdt('See {reference} in @cite{{book}}',
-                       $converter->get_conf('documentlanguage'),
-                       {'reference' => $tree_reference,
-                        'book'  => {'text' => $book_name}});
+  $tree = gdt('See {reference} in @cite{{book}}',
+              $converter->get_conf('documentlanguage'),
+              {'reference' => $tree_reference,
+               'book'  => {'text' => $book_name}});
 
 C<gdt> uses a gettext-like infrastructure to retrieve the
 translated strings, using the I<texinfo_document> domain.
 
-=item $tree = $object->pgdt($translation_context, $string, $lang, 
$replaced_substrings)
+=item $tree = pgdt($translation_context, $string, $lang, $replaced_substrings, 
$debug_level)
 X<C<pgdt>>
 
 Same to C<gdt> except that the I<$translation_context> is not optional.



reply via email to

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