[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Text.pm (_convert), tp/Texin
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Text.pm (_convert), tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): translated untranslated type using the documentlanguage extra information from the tree element if there is no converter available. |
Date: |
Fri, 02 Feb 2024 17:17:04 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 1cdf5630c7 * tp/Texinfo/Convert/Text.pm (_convert),
tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): translated
untranslated type using the documentlanguage extra information from the tree
element if there is no converter available.
1cdf5630c7 is described below
commit 1cdf5630c70e52929710e9033559f9370fd23870
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Feb 2 23:16:55 2024 +0100
* tp/Texinfo/Convert/Text.pm (_convert),
tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal):
translated untranslated type using the documentlanguage extra
information from the tree element if there is no converter
available.
---
ChangeLog | 8 +++++
tp/Texinfo/Convert/Text.pm | 37 ++++++++++++++--------
tp/Texinfo/XS/main/convert_to_text.c | 34 ++++++++++++++++----
tp/t/results/languages/documentlanguage.pl | 2 +-
tp/t/results/languages/documentlanguage_option.pl | 2 +-
.../results/languages/multiple_documentlanguage.pl | 4 +--
tp/t/results/languages/multiple_in_preamble.pl | 4 +--
.../languages/multiple_in_preamble_before_node.pl | 2 +-
tp/t/results/languages/multiple_lang_chapters.pl | 2 +-
.../languages/multiple_lang_chapters_latex.pl | 2 +-
.../languages/multiple_lang_chapters_texi2html.pl | 2 +-
tp/t/results/languages/simple_documentlanguage.pl | 2 +-
tp/t/results/languages/unknown_region.pl | 2 +-
13 files changed, 71 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d82b6198b4..e3f143bc44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-02 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Text.pm (_convert),
+ tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal):
+ translated untranslated type using the documentlanguage extra
+ information from the tree element if there is no converter
+ available.
+
2024-02-02 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/document.c
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 4a81c30a02..597ad2e7ac 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -43,6 +43,8 @@ use Texinfo::Convert::Texinfo;
# misc functions and data
use Texinfo::Convert::Utils;
+use Texinfo::Translations;
+
require Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@@ -547,22 +549,31 @@ sub _convert($$)
$element->{'cmdname'}})))));
my $result = '';
if (defined($element->{'text'})) {
- if ($element->{'type'} and $element->{'type'} eq 'untranslated'
- and $options and $options->{'converter'}) {
- # the tree documentlanguage corresponds to the documentlanguage
- # at the place of the tree, but the converter may want to use
- # another documentlanguage, for instance the documentlanguage at
- # the end of the preamble, so we let the converter set it.
- #my $tree = Texinfo::Translations::gdt(undef, $element->{'text'},
- # undef, $element->{'extra'}->{'documentlanguage'});
+ if ($element->{'type'} and $element->{'type'} eq 'untranslated') {
my $tree;
+ my $translation_context;
if ($element->{'extra'}
and $element->{'extra'}->{'translation_context'}) {
- $tree = $options->{'converter'}->pcdt(
- $element->{'extra'}->{'translation_context'},
- $element->{'text'});
+ $translation_context = $element->{'extra'}->{'translation_context'};
+ }
+
+ if ($options and $options->{'converter'}) {
+ # the tree documentlanguage corresponds to the documentlanguage
+ # at the place of the tree, but the converter may want to use
+ # another documentlanguage, for instance the documentlanguage at
+ # the end of the preamble, so we let the converter set it.
+ if ($translation_context) {
+ $tree = $options->{'converter'}->pcdt($translation_context,
+ $element->{'text'});
+ } else {
+ $tree = $options->{'converter'}->cdt($element->{'text'});
+ }
} else {
- $tree = $options->{'converter'}->cdt($element->{'text'});
+ # if there is no converter, we use the documentlanguage available
+ # in the tree.
+ $tree = Texinfo::Translations::gdt(undef, $element->{'text'},
+ $element->{'extra'}->{'documentlanguage'},
+ undef, $translation_context);
}
$result = _convert($options, $tree);
} else {
@@ -1135,7 +1146,7 @@ Texinfo to other formats. There is no promise of API
stability.
C<Texinfo::Convert::Text> is a simple backend that converts a Texinfo tree
to simple text. It is used in converters, especially for file names.
The conversion is very simple, and, in the default case, cannot handle
-output strings translation or error handling.
+error handling nor some output strings translation.
Converters derived from L<Texinfo::Convert::Converter> should have conversion
text options associated to the C<convert_text_options> key.
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index e099bb5df6..a0f8412962 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -522,20 +522,40 @@ convert_to_text_internal (const ELEMENT *element,
TEXT_OPTIONS *text_options,
/* or element->text.space? */
if (element->text.end > 0)
{
- if (element->type == ET_untranslated && text_options->converter)
+ if (element->type == ET_untranslated)
{
+ ELEMENT *tree = 0;
+ char *translation_context
+ = lookup_extra_string (element, "translation_context");
+
+ if (text_options->converter)
+ {
/*
the tree documentlanguage corresponds to the documentlanguage
at the place of the tree, but the converter may want to use
another documentlanguage, for instance the documentlanguage at
the end of the preamble, so we let the converter set it.
- documentlanguage = lookup_extra_string (element, "documentlanguage");
*/
- char *translation_context
- = lookup_extra_string (element, "translation_context");
- ELEMENT *tree = cdt_tree (element->text.text,
- text_options->converter,
- 0, translation_context);
+ tree = cdt_tree (element->text.text, text_options->converter,
+ 0, translation_context);
+ }
+ else
+ {
+ /* if there is no converter, we use the documentlanguage available
+ in the tree. */
+
+ const char *documentlanguage
+ = lookup_extra_string (element, "documentlanguage");
+
+ /* there is a possibility that some small strings are associated
+ to the tree, and there is no document to get them. However
+ it is very unlikely to have small strings given that the
+ converted tree should be very simple and is a string only,
+ no macro, no file */
+ tree = gdt_tree (element->text.text, 0, 0, documentlanguage,
+ 0, translation_context);
+ }
+
if (tree)
{
convert_to_text_internal (tree, text_options, result);
diff --git a/tp/t/results/languages/documentlanguage.pl
b/tp/t/results/languages/documentlanguage.pl
index ec37689da3..71fa0aaf44 100644
--- a/tp/t/results/languages/documentlanguage.pl
+++ b/tp/t/results/languages/documentlanguage.pl
@@ -736,7 +736,7 @@ top section
chapter.
-Method on class: data-type name arguments
+Método on class: data-type name arguments
Some text.
diff --git a/tp/t/results/languages/documentlanguage_option.pl
b/tp/t/results/languages/documentlanguage_option.pl
index 2c2ef9740f..514aa4c2c3 100644
--- a/tp/t/results/languages/documentlanguage_option.pl
+++ b/tp/t/results/languages/documentlanguage_option.pl
@@ -736,7 +736,7 @@ top section
chapter.
-Method on class: data-type name arguments
+Me\'thode on class: data-type name arguments
Some text.
diff --git a/tp/t/results/languages/multiple_documentlanguage.pl
b/tp/t/results/languages/multiple_documentlanguage.pl
index 37fc98d383..41f70fcdcb 100644
--- a/tp/t/results/languages/multiple_documentlanguage.pl
+++ b/tp/t/results/languages/multiple_documentlanguage.pl
@@ -1009,13 +1009,13 @@ top
1 Chap
******
-Instance Variable of fr: BBB CCC
+Variable d\'instance of fr: BBB CCC
error-->
-Instance Variable of hr: BBB CCC
+Primjerak varijable of hr: BBB CCC
error-->
diff --git a/tp/t/results/languages/multiple_in_preamble.pl
b/tp/t/results/languages/multiple_in_preamble.pl
index 1a31ada553..df0a12efe5 100644
--- a/tp/t/results/languages/multiple_in_preamble.pl
+++ b/tp/t/results/languages/multiple_in_preamble.pl
@@ -902,11 +902,11 @@ top section
1 chap
******
-Instance Variable of hr: BBB CCC
+Primjerak varijable of hr: BBB CCC
error-->
-Instance Variable of de: FFF GGG
+Instanzvariable of de: FFF GGG
';
$result_sectioning{'multiple_in_preamble'} = {
diff --git a/tp/t/results/languages/multiple_in_preamble_before_node.pl
b/tp/t/results/languages/multiple_in_preamble_before_node.pl
index 4874890649..eddced67ec 100644
--- a/tp/t/results/languages/multiple_in_preamble_before_node.pl
+++ b/tp/t/results/languages/multiple_in_preamble_before_node.pl
@@ -747,7 +747,7 @@ top section
1 chap
******
-Instance Variable of c: BBB CCC
+Instanzvariable of c: BBB CCC
error-->
';
diff --git a/tp/t/results/languages/multiple_lang_chapters.pl
b/tp/t/results/languages/multiple_lang_chapters.pl
index 9b05618c89..9cc7a4573b 100644
--- a/tp/t/results/languages/multiple_lang_chapters.pl
+++ b/tp/t/results/languages/multiple_lang_chapters.pl
@@ -1778,7 +1778,7 @@ Instance Variable of AAA: BBB CCC
3 fr_FR
*******
-Instance Variable of AAA: BBB CCC
+Variable d\'instance of AAA: BBB CCC
4 de
****
diff --git a/tp/t/results/languages/multiple_lang_chapters_latex.pl
b/tp/t/results/languages/multiple_lang_chapters_latex.pl
index fcdc31b639..44fc96af52 100644
--- a/tp/t/results/languages/multiple_lang_chapters_latex.pl
+++ b/tp/t/results/languages/multiple_lang_chapters_latex.pl
@@ -1778,7 +1778,7 @@ Instance Variable of AAA: BBB CCC
3 fr_FR
*******
-Instance Variable of AAA: BBB CCC
+Variable d\'instance of AAA: BBB CCC
4 de
****
diff --git a/tp/t/results/languages/multiple_lang_chapters_texi2html.pl
b/tp/t/results/languages/multiple_lang_chapters_texi2html.pl
index 516069c238..4b4882a5b5 100644
--- a/tp/t/results/languages/multiple_lang_chapters_texi2html.pl
+++ b/tp/t/results/languages/multiple_lang_chapters_texi2html.pl
@@ -1746,7 +1746,7 @@ Instance Variable of AAA: BBB CCC
3 fr_FR
*******
-Instance Variable of AAA: BBB CCC
+Variable d\'instance of AAA: BBB CCC
4 de
****
diff --git a/tp/t/results/languages/simple_documentlanguage.pl
b/tp/t/results/languages/simple_documentlanguage.pl
index 1190fbb099..4fe780ea31 100644
--- a/tp/t/results/languages/simple_documentlanguage.pl
+++ b/tp/t/results/languages/simple_documentlanguage.pl
@@ -303,7 +303,7 @@ $result_texis{'simple_documentlanguage'} =
'@documentlanguage fr
$result_texts{'simple_documentlanguage'} = '
-Instance Variable of AAA: BBB CCC
+Variable d\'instance of AAA: BBB CCC
';
$result_nodes{'simple_documentlanguage'} = [
diff --git a/tp/t/results/languages/unknown_region.pl
b/tp/t/results/languages/unknown_region.pl
index 51ec99ad72..20318a51ab 100644
--- a/tp/t/results/languages/unknown_region.pl
+++ b/tp/t/results/languages/unknown_region.pl
@@ -303,7 +303,7 @@ $result_texis{'unknown_region'} = '@documentlanguage
fr_NOWHERE
$result_texts{'unknown_region'} = '
-Instance Variable of AAA: BBB CCC
+Variable d\'instance of AAA: BBB CCC
';
$result_nodes{'unknown_region'} = [
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Text.pm (_convert), tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): translated untranslated type using the documentlanguage extra information from the tree element if there is no converter available.,
Patrice Dumas <=