texinfo-commits
[Top][All Lists]
Advanced

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

[7558] parse_def don't call gdt


From: gavinsmith0123
Subject: [7558] parse_def don't call gdt
Date: Tue, 20 Dec 2016 19:53:01 +0000 (UTC)

Revision: 7558
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7558
Author:   gavin
Date:     2016-12-20 19:53:01 +0000 (Tue, 20 Dec 2016)
Log Message:
-----------
parse_def don't call gdt

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Convert/HTML.pm
    trunk/tp/Texinfo/Convert/Plaintext.pm
    trunk/tp/Texinfo/Convert/Text.pm
    trunk/tp/Texinfo/Parser.pm
    trunk/tp/t/results/languages/multiple.pl
    trunk/tp/t/results/languages/multiple_lang_chapters.pl
    trunk/tp/t/results/languages/multiple_lang_chapters_texi2html.pl
    trunk/tp/t/results/languages/simple.pl
    trunk/tp/t/results/languages/unknown_region.pl

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2016-12-19 20:53:13 UTC (rev 7557)
+++ trunk/ChangeLog     2016-12-20 19:53:01 UTC (rev 7558)
@@ -1,3 +1,26 @@
+2016-12-20  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/Parser.pm (_parse_def): Instead of calling 'gdt' on 
+       inserted text, add an 'untranslated' element containing the 
+       untranslated text.
+       * tp/Texinfo/Convert/HTML.pm (_convert),
+       * tp/Texinfo/Convert/Text.pm (_convert):,
+       For 'untranslated' elements, call 'gdt' on the text.
+
+       This results in some changes to the test results:
+         Strings not translated in the results from Text.pm, but they
+       weren't properly translated before either.
+         Strings inside @copying translated according to document
+       language at time of @insertcopying, not time of @copying.
+
+
+2016-12-19  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/Common.pm (%def_map): Don't surround values 
+       containing spaces with braces.
+       * tp/Texinfo/Parser.pm (_parse_def): Always create a 'bracketed' 
+       element to contain prepended text.
+
 2016-12-18  Gavin Smith  <address@hidden>
 
        * tp/Texinfo/Convert/Text.pm (_convert): Delete disabled code 

Modified: trunk/tp/Texinfo/Convert/HTML.pm
===================================================================
--- trunk/tp/Texinfo/Convert/HTML.pm    2016-12-19 20:53:13 UTC (rev 7557)
+++ trunk/tp/Texinfo/Convert/HTML.pm    2016-12-20 19:53:01 UTC (rev 7558)
@@ -7376,6 +7376,11 @@
     if ($root->{'type'} and $root->{'type'} eq '_converted') {
       return $root->{'text'};
     }
+    if ($root->{'type'} and $root->{'type'} eq 'untranslated') {
+      my $translated = $self->gdt($root->{'text'});
+      my $result = $self->_convert($translated);
+      return $result;
+    }
     my $result = &{$self->{'types_conversion'}->{'text'}} ($self, 
                                                       $root->{'type'},
                                                       $root,

Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm       2016-12-19 20:53:13 UTC (rev 
7557)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm       2016-12-20 19:53:01 UTC (rev 
7558)
@@ -1649,25 +1649,31 @@
 
   # process text
   if (defined($root->{'text'})) {
-    if (!$formatter->{'_top_formatter'}) {
-      if ($root->{'type'} and ($root->{'type'} eq 'raw' 
-                               or $root->{'type'} eq 'last_raw_newline')) {
-        $result = _count_added($self, $formatter->{'container'},
-                    $formatter->{'container'}->add_next($root->{'text'}));
-      } else {
-        my $text = _process_text($self, $root, $formatter);
-        $result = _count_added($self, $formatter->{'container'},
-                    $formatter->{'container'}->add_text($text));
+    if (!$root->{'type'} or $root->{'type'} ne 'untranslated') {
+      if (!$formatter->{'_top_formatter'}) {
+        if ($root->{'type'} and ($root->{'type'} eq 'raw' 
+                                 or $root->{'type'} eq 'last_raw_newline')) {
+          $result = _count_added($self, $formatter->{'container'},
+                      $formatter->{'container'}->add_next($root->{'text'}));
+        } else {
+          my $text = _process_text($self, $root, $formatter);
+          $result = _count_added($self, $formatter->{'container'},
+                      $formatter->{'container'}->add_text($text));
+        }
+        return $result;
+      # the following is only possible if paragraphindent is set to asis
+      } elsif ($root->{'type'} and $root->{'type'} eq 
'empty_spaces_before_paragraph') {
+        _add_text_count($self, $root->{'text'});
+        return $root->{'text'};
+      # ignore text outside of any format, but warn if ignored text not empty
+      } elsif ($root->{'text'} =~ /\S/) {
+        $self->_bug_message("ignored text not empty `$root->{'text'}'", $root);
+        return '';
       }
-      return $result;
-    # the following is only possible if paragraphindent is set to asis
-    } elsif ($root->{'type'} and $root->{'type'} eq 
'empty_spaces_before_paragraph') {
-      _add_text_count($self, $root->{'text'});
-      return $root->{'text'};
-    # ignore text outside of any format, but warn if ignored text not empty
-    } elsif ($root->{'text'} =~ /\S/) {
-      $self->_bug_message("ignored text not empty `$root->{'text'}'", $root);
-      return '';
+    } else {
+      my $tree = $self->gdt($root->{'text'});
+      my $converted = $self->_convert($tree);
+      return $converted;
     }
   }
 

Modified: trunk/tp/Texinfo/Convert/Text.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Text.pm    2016-12-19 20:53:13 UTC (rev 7557)
+++ trunk/tp/Texinfo/Convert/Text.pm    2016-12-20 19:53:01 UTC (rev 7558)
@@ -373,20 +373,31 @@
                      and !$formatting_misc_commands{$root->{'cmdname'}})))));
   my $result = '';
   if (defined($root->{'text'})) {
-    $result = $root->{'text'};
-    if ((! defined($root->{'type'}) 
-         or $root->{'type'} ne 'raw')
-         and !$options->{'raw'}) {
-      if ($options->{'sc'}) {
-        $result = uc($result);
+    if ($root->{'type'} and $root->{'type'} eq 'untranslated'
+        and $options and $options->{'converter'}) {
+      my $save_lang = $options->{'converter'}->get_conf('documentlanguage');
+      $options->{'converter'}->{'documentlanguage'}
+        = $root->{'extra'}->{'documentlanguage'};
+      my $tree = Texinfo::Report::gdt($options->{'converter'},
+                                      $root->{'text'});
+      $result = _convert($tree, $options);
+      $options->{'converter'}->{'documentlanguage'} = $save_lang;
+    } else {
+      $result = $root->{'text'};
+      if ((! defined($root->{'type'}) 
+           or $root->{'type'} ne 'raw')
+           and !$options->{'raw'}) {
+        if ($options->{'sc'}) {
+          $result = uc($result);
+        }
+        if (!$options->{'code'}) {
+          $result =~ s/``/"/g;
+          $result =~ s/\'\'/"/g;
+          $result =~ s/---/\x{1F}/g;
+          $result =~ s/--/-/g;
+          $result =~ s/\x{1F}/--/g;
+        }
       }
-      if (!$options->{'code'}) {
-        $result =~ s/``/"/g;
-        $result =~ s/\'\'/"/g;
-        $result =~ s/---/\x{1F}/g;
-        $result =~ s/--/-/g;
-        $result =~ s/\x{1F}/--/g;
-      }
     }
   }
   if ($root->{'cmdname'}) {

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2016-12-19 20:53:13 UTC (rev 7557)
+++ trunk/tp/Texinfo/Parser.pm  2016-12-20 19:53:01 UTC (rev 7558)
@@ -2357,11 +2357,17 @@
     my $prepended = $def_map{$command}->{$real_command};
     my @prepended_content;
 
-    my $tree = $self->gdt($prepended);
+    my $tree = parse_texi_line(undef, $prepended);
+
     my $bracketed = { 'type' => 'bracketed' };
     $bracketed->{'contents'} = $tree->{'contents'};
     foreach my $content (@{$tree->{'contents'}}) {
       $content->{'parent'} = $bracketed;
+      if (!$content->{'type'} and $self->{'documentlanguage'}) {
+        $content->{'type'} = 'untranslated';
+        $content->{'extra'}->{'documentlanguage'}
+        = $self->{'documentlanguage'};
+      }
     }
     @prepended_content = ($bracketed);
     push @prepended_content, { 'text' => ' ' };

Modified: trunk/tp/t/results/languages/multiple.pl
===================================================================
--- trunk/tp/t/results/languages/multiple.pl    2016-12-19 20:53:13 UTC (rev 
7557)
+++ trunk/tp/t/results/languages/multiple.pl    2016-12-20 19:53:01 UTC (rev 
7558)
@@ -98,8 +98,12 @@
                         {
                           'contents' => [
                             {
+                              'extra' => {
+                                'documentlanguage' => 'fr'
+                              },
                               'parent' => {},
-                              'text' => 'Variable d\'instance'
+                              'text' => 'Instance Variable',
+                              'type' => 'untranslated'
                             }
                           ],
                           'type' => 'bracketed_def_content'
@@ -364,8 +368,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'fr'
+                          },
                           'parent' => {},
-                          'text' => 'Variable d\'instance'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -603,8 +611,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'pt'
+                          },
                           'parent' => {},
-                          'text' => 'Instance Variable'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -939,7 +951,7 @@
 $result_texts{'multiple'} = '
 
 
-Variable d\'instance of fr: BBB CCC
+Instance Variable of fr: BBB CCC
 
 
 
@@ -987,7 +999,7 @@
 
  -- Instance Variable da pt: BBB CCC
 
- -- Variable d\'instance da copying: a b
+ -- Instance Variable da copying: a b
 ';
 
 
@@ -1004,7 +1016,7 @@
 
  -- Instance Variable da pt: BBB CCC
 
- -- Variable d\'instance da copying: a b
+ -- Instance Variable da copying: a b
 
 
 Tag Table:
@@ -1016,7 +1028,7 @@
 
 $result_converted{'html'}->{'multiple'} = '<!DOCTYPE html PUBLIC "-//W3C//DTD 
HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd";>
 <html>
-<!-- Variable d\'instance da copying: a b -->
+<!-- Instance Variable da copying: a b -->
 <!-- Created by texinfo, http://www.gnu.org/software/texinfo/ -->
 <head>
 <title>Documento Sem Nome</title>
@@ -1079,7 +1091,7 @@
 </dl>
 
 <dl>
-<dt><a name="index-copying-a-of-copying"></a>Variable d\'instance da copying: 
<strong>a</strong> <em>b</em></dt>
+<dt><a name="index-copying-a-of-copying"></a>Instance Variable da copying: 
<strong>a</strong> <em>b</em></dt>
 </dl>
 
 <hr>

Modified: trunk/tp/t/results/languages/multiple_lang_chapters.pl
===================================================================
--- trunk/tp/t/results/languages/multiple_lang_chapters.pl      2016-12-19 
20:53:13 UTC (rev 7557)
+++ trunk/tp/t/results/languages/multiple_lang_chapters.pl      2016-12-20 
19:53:01 UTC (rev 7558)
@@ -760,8 +760,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'ja'
+                          },
                           'parent' => {},
-                          'text' => 'Instance Variable'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -1124,8 +1128,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'en'
+                          },
                           'parent' => {},
-                          'text' => 'Instance Variable'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -1437,8 +1445,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'fr_FR'
+                          },
                           'parent' => {},
-                          'text' => 'Variable d\'instance'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -2336,7 +2348,7 @@
 3 fr_FR
 *******
 
-Variable d\'instance of AAA: BBB CCC
+Instance Variable of AAA: BBB CCC
 
 4 de
 ****

Modified: trunk/tp/t/results/languages/multiple_lang_chapters_texi2html.pl
===================================================================
--- trunk/tp/t/results/languages/multiple_lang_chapters_texi2html.pl    
2016-12-19 20:53:13 UTC (rev 7557)
+++ trunk/tp/t/results/languages/multiple_lang_chapters_texi2html.pl    
2016-12-20 19:53:01 UTC (rev 7558)
@@ -760,8 +760,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'ja'
+                          },
                           'parent' => {},
-                          'text' => 'Instance Variable'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -1124,8 +1128,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'en'
+                          },
                           'parent' => {},
-                          'text' => 'Instance Variable'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -1437,8 +1445,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'fr_FR'
+                          },
                           'parent' => {},
-                          'text' => 'Variable d\'instance'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -2336,7 +2348,7 @@
 3 fr_FR
 *******
 
-Variable d\'instance of AAA: BBB CCC
+Instance Variable of AAA: BBB CCC
 
 4 de
 ****

Modified: trunk/tp/t/results/languages/simple.pl
===================================================================
--- trunk/tp/t/results/languages/simple.pl      2016-12-19 20:53:13 UTC (rev 
7557)
+++ trunk/tp/t/results/languages/simple.pl      2016-12-20 19:53:01 UTC (rev 
7558)
@@ -125,8 +125,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'fr'
+                          },
                           'parent' => {},
-                          'text' => 'Variable d\'instance'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -343,7 +347,7 @@
 
 $result_texts{'simple'} = '
 
-Variable d\'instance of AAA: BBB CCC
+Instance Variable of AAA: BBB CCC
 ';
 
 $result_sectioning{'simple'} = {};

Modified: trunk/tp/t/results/languages/unknown_region.pl
===================================================================
--- trunk/tp/t/results/languages/unknown_region.pl      2016-12-19 20:53:13 UTC 
(rev 7557)
+++ trunk/tp/t/results/languages/unknown_region.pl      2016-12-20 19:53:01 UTC 
(rev 7558)
@@ -125,8 +125,12 @@
                     {
                       'contents' => [
                         {
+                          'extra' => {
+                            'documentlanguage' => 'fr_NOWHERE'
+                          },
                           'parent' => {},
-                          'text' => 'Variable d\'instance'
+                          'text' => 'Instance Variable',
+                          'type' => 'untranslated'
                         }
                       ],
                       'type' => 'bracketed_def_content'
@@ -343,7 +347,7 @@
 
 $result_texts{'unknown_region'} = '
 
-Variable d\'instance of AAA: BBB CCC
+Instance Variable of AAA: BBB CCC
 ';
 
 $result_sectioning{'unknown_region'} = {};




reply via email to

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