[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 8 Nov 2022 03:29:23 -0500 (EST) |
branch: master
commit f1ace22fdf278763586e4937aa087b4e1ac044af
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 29 22:28:56 2022 +0200
* tp/Texinfo/Convert/HTML.pm (direction_string, _translate_names):
translate direction strings only when needed and cache them
afterwards. Remove the contents of the translated direction
string types in _translate_names such that they will be re-translated
in the next direction_string call.
---
ChangeLog | 8 ++++++++
tp/Texinfo/Convert/HTML.pm | 51 +++++++++++++++++++++++++---------------------
2 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c3390967f0..59edc91dbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-10-29 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (direction_string, _translate_names):
+ translate direction strings only when needed and cache them
+ afterwards. Remove the contents of the translated direction
+ string types in _translate_names such that they will be re-translated
+ in the next direction_string call.
+
2022-10-29 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_convert_informative_command, _convert):
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 86ec17a0e2..6cc621cd4e 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -1356,14 +1356,36 @@ sub direction_string($$$)
{
my $self = shift;
my $direction = shift;
- my $type = shift;
+ my $string_type = shift;
- if (!$valid_direction_string_type{$type}) {
- print STDERR "Incorrect type $type in direction_string call\n";
+ if (!$valid_direction_string_type{$string_type}) {
+ print STDERR "Incorrect type $string_type in direction_string call\n";
return undef;
}
- return $self->{'directions_strings'}->{$type}->{$direction};
+ if (not exists($self->{'directions_strings'}->{$string_type}->{$direction}))
{
+ my $translated_directions_strings =
$self->{'translated_direction_strings'};
+ if
(defined($translated_directions_strings->{$string_type}->{$direction}->{'converted'}))
{
+ # translate already converted direction strings
+ my $result_string
+ =
$self->gdt($translated_directions_strings->{$string_type}->{$direction}->{'converted'},
+ undef, undef, 'translated_text');
+ $self->{'directions_strings'}->{$string_type}->{$direction}
+ = $self->substitute_html_non_breaking_space($result_string);
+ } elsif
(defined($translated_directions_strings->{$string_type}->{$direction}->{'to_convert'}))
{
+ # translate direction strings that need to be translated and converted
+ my $translated_tree
+ =
$self->gdt($translated_directions_strings->{$string_type}->{$direction}->{'to_convert'});
+ my $result_string =
$self->convert_tree_new_formatting_context($translated_tree,
+ "direction $direction", undef, "direction
$direction");
+ $self->{'directions_strings'}->{$string_type}->{$direction}
+ = $result_string;
+ } else {
+ # FIXME or ''
+ $self->{'directions_strings'}->{$string_type}->{$direction} = undef;
+ }
+ }
+ return $self->{'directions_strings'}->{$string_type}->{$direction};
}
# API for misc conversion and formatting functions
@@ -1997,26 +2019,9 @@ sub _translate_names($)
." documentlanguage: ".$self->get_conf('documentlanguage')."\n"
if ($self->get_conf('DEBUG'));
- my $translated_directions_strings = $self->{'translated_direction_strings'};
+ # reset strings such that they are translated when needed.
foreach my $string_type (keys(%default_translated_directions_strings)) {
- foreach my $direction
(keys(%{$translated_directions_strings->{$string_type}})) {
- if
(defined($translated_directions_strings->{$string_type}->{$direction}->{'converted'}))
{
- # translate already converted direction strings
- my $result_string
- =
$self->gdt($translated_directions_strings->{$string_type}->{$direction}->{'converted'},
- undef, undef, 'translated_text');
- $self->{'directions_strings'}->{$string_type}->{$direction}
- = $self->substitute_html_non_breaking_space($result_string);
- } elsif
(defined($translated_directions_strings->{$string_type}->{$direction}->{'to_convert'}))
{
- # translate direction strings that need to be translated and converted
- my $translated_tree
- =
$self->gdt($translated_directions_strings->{$string_type}->{$direction}->{'to_convert'});
- my $result_string =
$self->convert_tree_new_formatting_context($translated_tree,
- "direction $direction", undef, "direction
$direction");
- $self->{'directions_strings'}->{$string_type}->{$direction}
- = $result_string;
- }
- }
+ $self->{'directions_strings'}->{$string_type} = {};
}
%SPECIAL_ELEMENTS_HEADING = (
- master updated (183227df2e -> 2dff71c663), Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08
- [no subject], Patrice Dumas, 2022/11/08