[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 0c3721b0929f602c8824584f2a3e026aa71cbc7f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 29 21:22:58 2022 +0200
* doc/texi2any_api.texi (Element Direction Information Type)
(Direction Strings, Getting Direction Strings), tp/Texinfo/Common.pm
(@variable_other_settables), tp/Texinfo/Config.pm
(texinfo_register_direction_string_info)
(GNUT_get_direction_string_info), tp/Texinfo/Convert/HTML.pm
(direction_string, _translate_names, converter_initialize)
(_initialize_output_state): change customization of direction strings
to be set with texinfo_register_direction_string_info, retrieved in
the converter by GNUT_get_direction_string_info, translated when
needed and retrieved in formatting code with direction_string, instead
of using curtomization variables. Remove the customization variables
BUTTONS_TEXT, BUTTONS_NAME, BUTTONS_GOTO, BUTTONS_REL,
BUTTONS_ACCESSKEY, BUTTONS_EXAMPLE. Update functions that used the
BUTTONS_* customization variables.
* tp/Texinfo/Convert/HTML.pm (ACTIVE_ICONS, PASSIVE_ICONS): do not
initialize ACTIVE_ICONS and PASSIVE_ICONS to empty strings, instead
set to undef the customization variables as a whole.
---
ChangeLog | 26 +-
doc/texi2any_api.texi | 119 +++++++---
tp/Texinfo/Common.pm | 7 +-
tp/Texinfo/Config.pm | 21 ++
tp/Texinfo/Convert/HTML.pm | 581 ++++++++++++++++++++++++---------------------
tp/Texinfo/Translations.pm | 4 +
6 files changed, 445 insertions(+), 313 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8237faaedc..883475b781 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,25 @@
+2022-10-29 Patrice Dumas <pertusus@free.fr>
+
+ * doc/texi2any_api.texi (Element Direction Information Type)
+ (Direction Strings, Getting Direction Strings), tp/Texinfo/Common.pm
+ (@variable_other_settables), tp/Texinfo/Config.pm
+ (texinfo_register_direction_string_info)
+ (GNUT_get_direction_string_info), tp/Texinfo/Convert/HTML.pm
+ (direction_string, _translate_names, converter_initialize)
+ (_initialize_output_state): change customization of direction strings
+ to be set with texinfo_register_direction_string_info, retrieved in
+ the converter by GNUT_get_direction_string_info, translated when
+ needed and retrieved in formatting code with direction_string, instead
+ of using curtomization variables. Remove the customization variables
+ BUTTONS_TEXT, BUTTONS_NAME, BUTTONS_GOTO, BUTTONS_REL,
+ BUTTONS_ACCESSKEY, BUTTONS_EXAMPLE. Update functions that used the
+ BUTTONS_* customization variables.
+
+ * tp/Texinfo/Convert/HTML.pm (ACTIVE_ICONS, PASSIVE_ICONS): do not
+ initialize ACTIVE_ICONS and PASSIVE_ICONS to empty strings, instead
+ set to undef the customization variables as a whole.
+
2022-11-07 Gavin Smith <gavinsmith0123@gmail.com>
* README-hacking: new ChangeLog file done
-Copyright 2022 Free Software Foundation, Inc.
-
-Copying and distribution of this file, with or without modification,
-are permitted in any medium without royalty provided the copyright
-notice and this notice are preserved.
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 910a90da00..2d555f243e 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -946,7 +946,9 @@ Up node element unit.
@end table
-@anchor{Element Direction Information Type}
+@node Element Direction Information Type
+@subsection Element Direction Information Type
+
@cindex Direction information type
@cindex Type, of direction information
The element directions also have types of information associated,
@@ -992,6 +994,63 @@ associated with the element unit direction in priority.
command number in the representation.
+@node Direction Strings
+@subsection Direction Strings
+
+Directions have strings associated, corresponding to their names, description
+or specific HTML keywords:
+
+@cindex Direction strings
+
+@table @code
+@item accesskey
+Direction @code{accesskey} attribute used in navigation.
+
+@item button
+Direction short name typically used for buttons.
+
+@item description
+Description of the direction.
+
+@item example
+Section number corresponding to the example used in the About special
+element text.
+
+@item rel
+Direction @code{rel} attribute used in navigation.
+
+@item text
+Direction text in a few words.
+@end table
+
+@cindex Translated direction strings
+@samp{button}, @samp{description} and @samp{text} are translated based
+on the document language.
+
+
+@node Direction Strings Customization
+@section Direction Strings Customization
+
+The direction strings can be customized with
+@code{texinfo_register_direction_string_info}:
+
+@defun texinfo_register_direction_string_info ($direction, @
+ $type, $converted_string, $string_to_convert)
+@var{$direction} is a direction (@pxref{Directions}), @var{type}
+is the type of string (@pxref{Direction Strings}). Both
+@var{$converted_string} and @var{$string_to_convert} are optional,
+if both are unset or @code{undef}, the direction string is unset.
+@var{$converted_string} is the string, already converted to HTML.
+Alternatively, @var{$string_to_convert} can be specified to set the
+string to the corresponding Texinfo code after translation
+and conversion to HTML.
+
+@var{$string_to_convert} is ignored for
+special strings that do not need to be translated and cannot contain
+Texinfo @@-commands (@samp{accesskey}, @samp{rel} and @samp{example}).
+@end defun
+
+
@node Simple Navigation Panel Customization
@section Simple Navigation Panel Customization
@@ -1059,18 +1118,14 @@ values is the following:
@table @emph
@item string with an element unit direction
-@vindex BUTTONS_TEXT
If icons are not used, the button is a link to the corresponding
-element whose text is defined by the value associated with the element
-direction in the hash associated with the @code{BUTTONS_TEXT} customization
-variable, surrounded by @samp{[} and
+element whose text is the @code{text} direction string
+(@pxref{Direction Strings}), surrounded by @samp{[} and
@samp{]}. If the element direction is @samp{ }, the @samp{[} and @samp{]}
are omitted.
@vindex ACTIVE_ICONS
-@vindex BUTTONS_NAME
@vindex PASSIVE_ICONS
-@vindex BUTTONS_GOTO
@cindex Icons, in navigation buttons
If icons are used, the button is an image whose file is determined by
the value associated with the element direction in the
@@ -1078,9 +1133,10 @@ the value associated with the element direction in the
@code{PASSIVE_ICONS} variable hash if there is no element to link to. If
there is a link to the element, the icon links to that element. The
button name and button description are given as HTML attributes to
-have a textual description of the icon. The corresponding strings are
-in the @code{BUTTONS_NAME} variable hash for the button name and
-@code{BUTTONS_GOTO} variable hash for a more detailed description.
+have a textual description of the icon. The corresponding strings
+correspond to the @code{button} direction string for the button name
+and the @code{description} for a more detailed description (@pxref{Direction
+Strings}).
@item function reference
The function is called with one boolean argument, true if the
@@ -1123,19 +1179,17 @@ based on the name of the node associated with the next
section element unit.
@end table
@anchor{Accesskey and @code{rel} Navigation}
-@vindex BUTTONS_ACCESSKEY
@cindex @code{accesskey} navigation
If the customization variable @code{USE_ACCESSKEY} is set, the
-@code{accesskey} attribute is used in navigation. The
-@code{BUTTONS_ACCESSKEY} customization variable hash is then used for the
-@code{accesskey} attributes.
+@code{accesskey} attribute is used in navigation. The @code{accesskey}
+direction string is then used for the @code{accesskey} attributes
+(@pxref{Direction Strings}).
-@vindex BUTTONS_REL@r{, for navigation}
@cindex @code{rel} navigation
Similarly, if the @code{USE_REL_REV} customization variable is set,
the @code{rel} attribute is used in navigation. In that case the
-@code{BUTTONS_REL} customization variable hash is used for the @code{rel}
-attribute.
+@code{rel} direction string is used for the @code{rel}
+attribute (@pxref{Direction Strings}).
@node User Defined Functions
@@ -2626,8 +2680,8 @@ the navigation panel (@pxref{Simple Navigation Panel
Customization}).
@deftypefn {Function Reference} @var{$text} format_button_icon_img @
(@var{$converter}, @var{$button}, @var{$icon}, @var{$name})
-@var{$button} is a button name, typically obtained from the @code{BUTTONS_NAME}
-customization variable hash using a direction as key (@pxref{Directions}).
+@var{$button} is a button name, typically obtained from the @code{button}
+direction string (@pxref{Direction Strings}).
@var{$icon} is an image file name to be used as icon. @var{$name} is the
direction heading, typically formatted in string context. @xref{Init File
Expansion Contexts}.
@@ -2935,6 +2989,21 @@ commands, @code{@@printindex} and @code{@@listoffloats}
formatting requires
directions, links, labels and files information.
+@node Getting Direction Strings
+@section Getting Direction Strings
+
+@cindex Direction strings, getting
+
+To get direction strings, use @code{direction_string}:
+
+@deftypefun {@var{$string} =} @var{$converter}->direction_string @
+ (@var{$direction}, @var{string_type})
+Retrieve the @var{$direction} (@pxref{Directions}) string of type
+@var{string_type} (@pxref{Direction Strings}). The string will be translated
+if needed.
+@end deftypefun
+
+
@node Target Commands Links@comma{} Texts and Associated Commands
@section Target Commands Links, Texts and Associated Commands
@@ -3344,15 +3413,11 @@ conversion function, depending on the
@code{CONTENTS_OUTPUT_LOCATION} value.
The default About element has an explanation of the buttons used in
the document, controlled by @code{SECTION_BUTTONS}.
-The formatting of this text may be influenced by
-@code{BUTTONS_GOTO}, @code{BUTTONS_NAME}, @code{ACTIVE_ICONS}
+The formatting of this is influenced by
+the @code{text}, @code{description} and @code{example}
+direction strings (@pxref{Direction Strings}) and by @code{ACTIVE_ICONS}
(@pxref{Simple Navigation Panel Customization}).
-@vindex BUTTONS_EXAMPLE
-@code{BUTTONS_EXAMPLE} also influences the formatting. The keys of this hash
-are element directions (@pxref{Directions}) and the values
-are the text from the About example, typically a section number.
-
@vindex PROGRAM_NAME_IN_ABOUT
@code{PROGRAM_NAME_IN_ABOUT} can also be used to change the beginning of
the About element formatting.
@@ -3443,7 +3508,7 @@ The buttons images can be formatted with
@code{format_button_icon_img}
Customization information described in @ref{Simple Navigation Panel
Customization}
such as @code{BUTTONS_TEXT}, @code{BUTTONS_NAME}, @code{BUTTONS_GOTO},
-@code{USE_ACCESSKEY}, @code{BUTTONS_ACCESSKEY},
+@code{USE_ACCESSKEY},
@code{USE_REL_REV} and @code{BUTTONS_REL} can be relevant for the
formatting of a button.
@end deftypefn
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index d01ccc3515..168059e83d 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -434,12 +434,11 @@ our @variable_string_settables = (
# Not strings. Not documented in the manual nor elsewhere.
# FIXME To be documented somewhere, but where?
my @variable_other_settables = (
- 'LINKS_BUTTONS', 'TOP_BUTTONS', 'SECTION_BUTTONS', 'BUTTONS_TEXT',
- 'BUTTONS_ACCESSKEY', 'BUTTONS_REL', 'BUTTONS_GOTO',
+ 'LINKS_BUTTONS', 'TOP_BUTTONS', 'SECTION_BUTTONS',
'CHAPTER_FOOTER_BUTTONS', 'SECTION_FOOTER_BUTTONS',
'NODE_FOOTER_BUTTONS',
- 'MISC_BUTTONS', 'CHAPTER_BUTTONS', 'BUTTONS_NAME',
- 'BUTTONS_EXAMPLE', 'SPECIAL_ELEMENTS_HEADING', 'SPECIAL_ELEMENTS_CLASS',
+ 'MISC_BUTTONS', 'CHAPTER_BUTTONS',
+ 'SPECIAL_ELEMENTS_HEADING', 'SPECIAL_ELEMENTS_CLASS',
'SPECIAL_ELEMENTS_DIRECTIONS',
'ACTIVE_ICONS', 'PASSIVE_ICONS',
# set from command line
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index cf813d5ad9..cc0f51cb7a 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -396,6 +396,7 @@ my $GNUT_no_arg_commands_formatting_strings = {};
my $GNUT_style_commands_formatting_info = {};
my $GNUT_accent_command_formatting_info = {};
my $GNUT_types_formatting_info = {};
+my $GNUT_direction_string_info = {};
# called from init files
sub texinfo_register_file_id_setting_function($$)
@@ -644,6 +645,26 @@ sub GNUT_get_types_formatting_info()
return { %$GNUT_types_formatting_info };
}
+# no check on type and direction, but only the ones known in the HTML
+# converted will be used
+sub texinfo_register_direction_string_info($$;$$)
+{
+ my $direction = shift;
+ my $type = shift;
+ my $converted_string = shift;
+ my $string_to_convert = shift;
+
+ $GNUT_direction_string_info->{$type} = {}
+ if (not exists($GNUT_direction_string_info->{$type}));
+ $GNUT_direction_string_info->{$type}->{$direction}
+ = {'to_convert' => $string_to_convert, 'converted' => $converted_string};
+}
+
+sub GNUT_get_direction_string_info()
+{
+ return { %$GNUT_direction_string_info };
+}
+
#####################################################################
# the objective of this small package is to be in another
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index c8479d9633..fce91f2b33 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -1336,6 +1336,36 @@ sub from_element_direction($$$;$$$)
}
}
+
+my %valid_direction_string_type = (
+ # accesskey associated to the direction
+ 'accesskey' => 1,
+ # direction button name
+ 'button' => 1,
+ # description of the direction
+ 'description' => 1,
+ # section number corresponding to the example in About text
+ 'example' => 1,
+ # rel/ref string associated to the direction
+ 'rel' => 1,
+ # few words text associated to the direction
+ 'text' => 1,
+);
+
+sub direction_string($$$)
+{
+ my $self = shift;
+ my $direction = shift;
+ my $type = shift;
+
+ if (!$valid_direction_string_type{$type}) {
+ print STDERR "Incorrect type $type in direction_string call\n";
+ return undef;
+ }
+
+ return $self->{'directions_strings'}->{$type}->{$direction};
+}
+
# API for misc conversion and formatting functions
# it is considered 'top' only if element corresponds to @top or
@@ -1646,141 +1676,7 @@ sub convert_tree_new_formatting_context($$;$$$)
return $result;
}
-# see http://www.w3.org/TR/REC-html40/types.html#type-links
-my %BUTTONS_REL =
-(
- 'Top', 'start',
- 'Contents', 'contents',
- 'Overview', '',
- 'Index', 'index',
- 'This', '',
- 'Back', 'prev',
- 'FastBack', '',
- 'Prev', 'prev',
- 'Up', 'up',
- 'Next', 'next',
- 'NodeUp', 'up',
- 'NodeNext', 'next',
- 'NodePrev', 'prev',
- 'NodeForward', '',
- 'NodeBack', '',
- 'Forward', 'next',
- 'FastForward', '',
- 'About' , 'help',
- 'First', '',
- 'Last', '',
- 'NextFile', 'next',
- 'PrevFile', 'prev',
-);
-
-my %BUTTONS_ACCESSKEY =
-(
- 'Top', '',
- 'Contents', '',
- 'Overview', '',
- 'Index', '',
- 'This', '',
- 'Back', 'p',
- 'FastBack', '',
- 'Prev', 'p',
- 'Up', 'u',
- 'Next', 'n',
- 'NodeUp', 'u',
- 'NodeNext', 'n',
- 'NodePrev', 'p',
- 'NodeForward', '',
- 'NodeBack', '',
- 'Forward', 'n',
- 'FastForward', '',
- 'About' , '',
- 'First', '',
- 'Last', '',
- 'NextFile', '',
- 'PrevFile', '',
-);
-
-my %BUTTONS_EXAMPLE =
- (
- 'Top', ' '.$html_default_entity_nbsp.' ',
- 'Contents', ' '.$html_default_entity_nbsp.' ',
- 'Overview', ' '.$html_default_entity_nbsp.' ',
- 'Index', ' '.$html_default_entity_nbsp.' ',
- 'This', '1.2.3',
- 'Back', '1.2.2',
- 'FastBack', '1',
- 'Prev', '1.2.2',
- 'Up', '1.2',
- 'Next', '1.2.4',
- 'NodeUp', '1.2',
- 'NodeNext', '1.2.4',
- 'NodePrev', '1.2.2',
- 'NodeForward', '1.2.4',
- 'NodeBack', '1.2.2',
- 'Forward', '1.2.4',
- 'FastForward', '2',
- 'About', ' '.$html_default_entity_nbsp.' ',
- 'First', '1.',
- 'Last', '1.2.4',
- 'NextFile', ' '.$html_default_entity_nbsp.' ',
- 'PrevFile', ' '.$html_default_entity_nbsp.' ',
- );
-
-
-# insert here name of icon images for buttons
-# Icons are used, if ICONS and resp. value are set
-my %ACTIVE_ICONS = (
- 'Top', '',
- 'Contents', '',
- 'Overview', '',
- 'Index', '',
- 'This', '',
- 'Back', '',
- 'FastBack', '',
- 'Prev', '',
- 'Up', '',
- 'Next', '',
- 'NodeUp', '',
- 'NodeNext', '',
- 'NodePrev', '',
- 'NodeForward', '',
- 'NodeBack', '',
- 'Forward', '',
- 'FastForward', '',
- 'About' , '',
- 'First', '',
- 'Last', '',
- 'NextFile', '',
- 'PrevFile', '',
- ' ', '',
-);
-
-# insert here name of icon images for these, if button is inactive
-my %PASSIVE_ICONS = (
- 'Top', '',
- 'Contents', '',
- 'Overview', '',
- 'Index', '',
- 'This', '',
- 'Back', '',
- 'FastBack', '',
- 'Prev', '',
- 'Up', '',
- 'Next', '',
- 'NodeUp', '',
- 'NodeNext', '',
- 'NodePrev', '',
- 'NodeForward', '',
- 'NodeBack', '',
- 'Forward', '',
- 'FastForward', '',
- 'About', '',
- 'First', '',
- 'Last', '',
- 'NextFile', '',
- 'PrevFile', '',
-);
-
-my (%BUTTONS_TEXT, %BUTTONS_GOTO, %BUTTONS_NAME, %SPECIAL_ELEMENTS_HEADING);
+my %SPECIAL_ELEMENTS_HEADING;
my %defaults = (
'AVOID_MENU_REDUNDANCY' => 0,
@@ -1873,14 +1769,8 @@ my %defaults = (
'FOOTNOTE_END_HEADER_LEVEL' => 4,
'FOOTNOTE_SEPARATE_HEADER_LEVEL' => 4,
- 'BUTTONS_REL' => \%BUTTONS_REL,
- 'BUTTONS_ACCESSKEY' => \%BUTTONS_ACCESSKEY,
- 'BUTTONS_EXAMPLE' => \%BUTTONS_EXAMPLE,
- 'BUTTONS_GOTO' => \%BUTTONS_GOTO,
- 'BUTTONS_NAME' => \%BUTTONS_NAME,
- 'BUTTONS_TEXT' => \%BUTTONS_TEXT,
- 'ACTIVE_ICONS' => \%ACTIVE_ICONS,
- 'PASSIVE_ICONS' => \%PASSIVE_ICONS,
+ 'ACTIVE_ICONS' => undef,
+ 'PASSIVE_ICONS' => undef,
'SPECIAL_ELEMENTS_HEADING' => \%SPECIAL_ELEMENTS_HEADING,
'SPECIAL_ELEMENTS_CLASS' => {
'about' => 'about',
@@ -1917,10 +1807,185 @@ foreach my $special_element_variety (keys
%{$defaults{'SPECIAL_ELEMENTS_DIRECTIO
$global_and_special_directions{$defaults{'SPECIAL_ELEMENTS_DIRECTIONS'}->{$special_element_variety}}
= 1;
}
-foreach my $hash (\%BUTTONS_REL, \%BUTTONS_ACCESSKEY,
- \%ACTIVE_ICONS, \%PASSIVE_ICONS) {
- foreach my $button (grep {not exists($global_and_special_directions{$_}) and
$_ ne ' '} keys %$hash) {
- $hash->{'FirstInFile'.$button} = $hash->{$button};
+my %default_converted_directions_strings = (
+
+ # see http://www.w3.org/TR/REC-html40/types.html#type-links
+ 'rel' =>
+ {
+ 'Top', 'start',
+ 'Contents', 'contents',
+ 'Overview', '',
+ 'Index', 'index',
+ 'This', '',
+ 'Back', 'prev',
+ 'FastBack', '',
+ 'Prev', 'prev',
+ 'Up', 'up',
+ 'Next', 'next',
+ 'NodeUp', 'up',
+ 'NodeNext', 'next',
+ 'NodePrev', 'prev',
+ 'NodeForward', '',
+ 'NodeBack', '',
+ 'Forward', 'next',
+ 'FastForward', '',
+ 'About' , 'help',
+ 'First', '',
+ 'Last', '',
+ 'NextFile', 'next',
+ 'PrevFile', 'prev',
+ },
+
+ 'accesskey' =>
+ {
+ 'Top', '',
+ 'Contents', '',
+ 'Overview', '',
+ 'Index', '',
+ 'This', '',
+ 'Back', 'p',
+ 'FastBack', '',
+ 'Prev', 'p',
+ 'Up', 'u',
+ 'Next', 'n',
+ 'NodeUp', 'u',
+ 'NodeNext', 'n',
+ 'NodePrev', 'p',
+ 'NodeForward', '',
+ 'NodeBack', '',
+ 'Forward', 'n',
+ 'FastForward', '',
+ 'About' , '',
+ 'First', '',
+ 'Last', '',
+ 'NextFile', '',
+ 'PrevFile', '',
+ },
+
+ 'example' =>
+ {
+ 'Top', ' '.$html_default_entity_nbsp.' ',
+ 'Contents', ' '.$html_default_entity_nbsp.' ',
+ 'Overview', ' '.$html_default_entity_nbsp.' ',
+ 'Index', ' '.$html_default_entity_nbsp.' ',
+ 'This', '1.2.3',
+ 'Back', '1.2.2',
+ 'FastBack', '1',
+ 'Prev', '1.2.2',
+ 'Up', '1.2',
+ 'Next', '1.2.4',
+ 'NodeUp', '1.2',
+ 'NodeNext', '1.2.4',
+ 'NodePrev', '1.2.2',
+ 'NodeForward', '1.2.4',
+ 'NodeBack', '1.2.2',
+ 'Forward', '1.2.4',
+ 'FastForward', '2',
+ 'About', ' '.$html_default_entity_nbsp.' ',
+ 'First', '1.',
+ 'Last', '1.2.4',
+ 'NextFile', ' '.$html_default_entity_nbsp.' ',
+ 'PrevFile', ' '.$html_default_entity_nbsp.' ',
+ },
+);
+
+foreach my $string_type (keys(%default_converted_directions_strings)) {
+ foreach my $button (grep
+ {not exists($global_and_special_directions{$_}) and $_ ne ' '}
+ keys %{$default_converted_directions_strings{$string_type}}) {
+
$default_converted_directions_strings{$string_type}->{'FirstInFile'.$button}
+ = $default_converted_directions_strings{$string_type}->{$button};
+ }
+}
+
+my %default_translated_directions_strings = (
+ 'text' => {
+ ' ' => {'converted' => ' '.$html_default_entity_nbsp.' '},
+ 'Top' => {'to_convert' => Texinfo::Common::gdt('Top')},
+ 'Contents' => {'to_convert' => Texinfo::Common::gdt('Contents')},
+ 'Overview' => {'to_convert' => Texinfo::Common::gdt('Overview')},
+ 'Index' => {'to_convert' => Texinfo::Common::gdt('Index')},
+ 'This' => {'to_convert' => Texinfo::Common::gdt('current')},
+ 'Back' => {'converted' => ' < '},
+ 'FastBack' => {'converted' => ' << '},
+ 'Prev' => {'to_convert' => Texinfo::Common::gdt('Prev')},
+ 'Up' => {'to_convert' => Texinfo::Common::gdt(' Up ')},
+ 'Next' => {'to_convert' => Texinfo::Common::gdt('Next')},
+ #'NodeUp' => {'to_convert' => Texinfo::Common::gdt('Node up')},
+ 'NodeUp' => {'to_convert' => Texinfo::Common::gdt('Up')},
+ #'NodeNext' => {'to_convert' => Texinfo::Common::gdt('Next node')},
+ 'NodeNext' => {'to_convert' => Texinfo::Common::gdt('Next')},
+ #'NodePrev' => {'to_convert' => Texinfo::Common::gdt('Previous node')},
+ 'NodePrev' => {'to_convert' => Texinfo::Common::gdt('Previous')},
+ 'NodeForward' => {'to_convert' => Texinfo::Common::gdt('Forward node')},
+ 'NodeBack' => {'to_convert' => Texinfo::Common::gdt('Back node')},
+ 'Forward' => {'converted' => ' > '},
+ 'FastForward' => {'converted' => ' >> '},
+ 'About' => {'converted' => ' ? '},
+ 'First' => {'converted' => ' |< '},
+ 'Last' => {'converted' => ' >| '},
+ 'NextFile' => {'to_convert' => Texinfo::Common::gdt('Next file')},
+ 'PrevFile' => {'to_convert' => Texinfo::Common::gdt('Previous file')},
+ },
+
+ 'description' => {
+ 'Top' => {'to_convert' => Texinfo::Common::gdt('Cover (top) of
document')},
+ 'Contents' => {'to_convert' => Texinfo::Common::gdt('Table of
contents')},
+ 'Overview' => {'to_convert' => Texinfo::Common::gdt('Short table of
contents')},
+ 'Index' => {'to_convert' => Texinfo::Common::gdt('Index')},
+ 'This' => {'to_convert' => Texinfo::Common::gdt('Current
section')},
+ 'Back' => {'to_convert' => Texinfo::Common::gdt('Previous section
in reading order')},
+ 'FastBack' => {'to_convert' => Texinfo::Common::gdt('Beginning of this
chapter or previous chapter')},
+ 'Prev' => {'to_convert' => Texinfo::Common::gdt('Previous section
on same level')},
+ 'Up' => {'to_convert' => Texinfo::Common::gdt('Up section')},
+ 'Next' => {'to_convert' => Texinfo::Common::gdt('Next section on
same level')},
+ 'NodeUp' => {'to_convert' => Texinfo::Common::gdt('Up node')},
+ 'NodeNext' => {'to_convert' => Texinfo::Common::gdt('Next node')},
+ 'NodePrev' => {'to_convert' => Texinfo::Common::gdt('Previous node')},
+ 'NodeForward' => {'to_convert' => Texinfo::Common::gdt('Next node in node
reading order')},
+ 'NodeBack' => {'to_convert' => Texinfo::Common::gdt('Previous node in
node reading order')},
+ 'Forward' => {'to_convert' => Texinfo::Common::gdt('Next section in
reading order')},
+ 'FastForward' => {'to_convert' => Texinfo::Common::gdt('Next chapter')},
+ 'About' => {'to_convert' => Texinfo::Common::gdt('About (help)')},
+ 'First' => {'to_convert' => Texinfo::Common::gdt('First section in
reading order')},
+ 'Last' => {'to_convert' => Texinfo::Common::gdt('Last section in
reading order')},
+ 'NextFile' => {'to_convert' => Texinfo::Common::gdt('Forward section
in next file')},
+ 'PrevFile' => {'to_convert' => Texinfo::Common::gdt('Back section in
previous file')},
+ },
+
+ 'button' => {
+ ' ' => {'converted' => ' '},
+ 'Top' => {'to_convert' => Texinfo::Common::gdt('Top')},
+ 'Contents' => {'to_convert' => Texinfo::Common::gdt('Contents')},
+ 'Overview' => {'to_convert' => Texinfo::Common::gdt('Overview')},
+ 'Index' => {'to_convert' => Texinfo::Common::gdt('Index')},
+ 'This' => {'to_convert' => Texinfo::Common::gdt('This')},
+ 'Back' => {'to_convert' => Texinfo::Common::gdt('Back')},
+ 'FastBack' => {'to_convert' => Texinfo::Common::gdt('FastBack')},
+ 'Prev' => {'to_convert' => Texinfo::Common::gdt('Prev')},
+ 'Up' => {'to_convert' => Texinfo::Common::gdt('Up')},
+ 'Next' => {'to_convert' => Texinfo::Common::gdt('Next')},
+ 'NodeUp' => {'to_convert' => Texinfo::Common::gdt('NodeUp')},
+ 'NodeNext' => {'to_convert' => Texinfo::Common::gdt('NodeNext')},
+ 'NodePrev' => {'to_convert' => Texinfo::Common::gdt('NodePrev')},
+ 'NodeForward' => {'to_convert' => Texinfo::Common::gdt('NodeForward')},
+ 'NodeBack' => {'to_convert' => Texinfo::Common::gdt('NodeBack')},
+ 'Forward' => {'to_convert' => Texinfo::Common::gdt('Forward')},
+ 'FastForward' => {'to_convert' => Texinfo::Common::gdt('FastForward')},
+ 'About' => {'to_convert' => Texinfo::Common::gdt('About')},
+ 'First' => {'to_convert' => Texinfo::Common::gdt('First')},
+ 'Last' => {'to_convert' => Texinfo::Common::gdt('Last')},
+ 'NextFile' => {'to_convert' => Texinfo::Common::gdt('NextFile')},
+ 'PrevFile' => {'to_convert' => Texinfo::Common::gdt('PrevFile')},
+ }
+);
+
+foreach my $string_type (keys(%default_translated_directions_strings)) {
+ foreach my $button (grep
+ {not exists($global_and_special_directions{$_}) and $_ ne ' '}
+ keys %{$default_translated_directions_strings{$string_type}})
{
+
$default_translated_directions_strings{$string_type}->{'FirstInFile'.$button}
+ = $default_translated_directions_strings{$string_type}->{$button};
}
}
@@ -1931,97 +1996,26 @@ sub _translate_names($)
." documentlanguage: ".$self->get_conf('documentlanguage')."\n"
if ($self->get_conf('DEBUG'));
-
- %BUTTONS_TEXT = (
- 'Top', $self->gdt('Top'),
- 'Contents', $self->gdt('Contents'),
- 'Overview', $self->gdt('Overview'),
- 'Index', $self->gdt('Index'),
- ' ', ' '.$self->get_info('non_breaking_space').' ',
- 'This', $self->gdt('current'),
- 'Back', ' < ',
- 'FastBack', ' << ',
- 'Prev', $self->gdt('Prev'),
- 'Up', $self->gdt(' Up '),
- 'Next', $self->gdt('Next'),
- #'NodeUp', $self->gdt('Node up'),
- 'NodeUp', $self->gdt('Up'),
- #'NodeNext', $self->gdt('Next node'),
- 'NodeNext', $self->gdt('Next'),
- #'NodePrev', $self->gdt('Previous node'),
- 'NodePrev', $self->gdt('Previous'),
- 'NodeForward', $self->gdt('Forward node'),
- 'NodeBack', $self->gdt('Back node'),
- 'Forward', ' > ',
- 'FastForward', ' >> ',
- 'About', ' ? ',
- 'First', ' |< ',
- 'Last', ' >| ',
- 'NextFile', $self->gdt('Next file'),
- 'PrevFile', $self->gdt('Previous file'),
- );
-
- foreach my $button (grep {not exists($global_and_special_directions{$_}) and
$_ ne ' '} keys %BUTTONS_TEXT) {
- $BUTTONS_TEXT{'FirstInFile'.$button} = $BUTTONS_TEXT{$button};
- }
-
- %BUTTONS_GOTO = (
- 'Top', $self->gdt('Cover (top) of document'),
- 'Contents', $self->gdt('Table of contents'),
- 'Overview', $self->gdt('Short table of contents'),
- 'Index', $self->gdt('Index'),
- 'This', $self->gdt('Current section'),
- 'Back', $self->gdt('Previous section in reading order'),
- 'FastBack', $self->gdt('Beginning of this chapter or previous
chapter'),
- 'Prev', $self->gdt('Previous section on same level'),
- 'Up', $self->gdt('Up section'),
- 'Next', $self->gdt('Next section on same level'),
- 'NodeUp', $self->gdt('Up node'),
- 'NodeNext', $self->gdt('Next node'),
- 'NodePrev', $self->gdt('Previous node'),
- 'NodeForward', $self->gdt('Next node in node reading order'),
- 'NodeBack', $self->gdt('Previous node in node reading order'),
- 'Forward', $self->gdt('Next section in reading order'),
- 'FastForward', $self->gdt('Next chapter'),
- 'About' , $self->gdt('About (help)'),
- 'First', $self->gdt('First section in reading order'),
- 'Last', $self->gdt('Last section in reading order'),
- 'NextFile', $self->gdt('Forward section in next file'),
- 'PrevFile', $self->gdt('Back section in previous file'),
- );
-
- foreach my $button (grep {not exists($global_and_special_directions{$_}) and
$_ ne ' '} keys %BUTTONS_GOTO) {
- $BUTTONS_GOTO{'FirstInFile'.$button} = $BUTTONS_GOTO{$button};
- }
-
- %BUTTONS_NAME = (
- 'Top', $self->gdt('Top'),
- 'Contents', $self->gdt('Contents'),
- 'Overview', $self->gdt('Overview'),
- 'Index', $self->gdt('Index'),
- ' ', ' ',
- 'This', $self->gdt('This'),
- 'Back', $self->gdt('Back'),
- 'FastBack', $self->gdt('FastBack'),
- 'Prev', $self->gdt('Prev'),
- 'Up', $self->gdt('Up'),
- 'Next', $self->gdt('Next'),
- 'NodeUp', $self->gdt('NodeUp'),
- 'NodeNext', $self->gdt('NodeNext'),
- 'NodePrev', $self->gdt('NodePrev'),
- 'NodeForward', $self->gdt('NodeForward'),
- 'NodeBack', $self->gdt('NodeBack'),
- 'Forward', $self->gdt('Forward'),
- 'FastForward', $self->gdt('FastForward'),
- 'About', $self->gdt('About'),
- 'First', $self->gdt('First'),
- 'Last', $self->gdt('Last'),
- 'NextFile', $self->gdt('NextFile'),
- 'PrevFile', $self->gdt('PrevFile'),
- );
-
- foreach my $button (grep {not exists($global_and_special_directions{$_}) and
$_ ne ' '} keys %BUTTONS_NAME) {
- $BUTTONS_NAME{'FirstInFile'.$button} = $BUTTONS_NAME{$button};
+ my $translated_directions_strings = $self->{'translated_direction_strings'};
+ 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, '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;
+ }
+ }
}
%SPECIAL_ELEMENTS_HEADING = (
@@ -2047,14 +2041,6 @@ sub _translate_names($)
}
}
- foreach my $hash (\%BUTTONS_TEXT, \%BUTTONS_GOTO, \%BUTTONS_NAME) {
- foreach my $button (keys (%$hash)) {
- if (ref($hash->{$button})) {
- $hash->{$button} = $self->convert_tree_new_formatting_context(
- $hash->{$button}, "button $button", undef, "button
$button");
- }
- }
- }
my %translated_commands;
foreach my $context ('normal', 'preformatted', 'string', 'css_string') {
foreach my $command
(keys(%{$self->{'no_arg_commands_formatting'}->{$context}})) {
@@ -3317,7 +3303,7 @@ sub _default_panel_button_dynamic_direction($$;$$$)
}
if (defined($hyperlink)) {
# i18n
- $result = $self->get_conf('BUTTONS_TEXT')->{$direction}.": $hyperlink";
+ $result = $self->direction_string($direction, 'text').": $hyperlink";
}
# 1 to communicate that a delimiter is needed for that button
return ($result, 1);
@@ -3379,15 +3365,14 @@ sub _direction_href_attributes($$)
my $direction = shift;
my $href_attributes = '';
- if ($self->get_conf('USE_ACCESSKEY')
- and $self->get_conf('BUTTONS_ACCESSKEY')) {
- my $accesskey = $self->get_conf('BUTTONS_ACCESSKEY')->{$direction};
+ if ($self->get_conf('USE_ACCESSKEY')) {
+ my $accesskey = $self->direction_string($direction, 'accesskey');
if (defined($accesskey) and ($accesskey ne '')) {
$href_attributes = " accesskey=\"$accesskey\"";
}
}
- if ($self->get_conf('USE_REL_REV') and $self->get_conf('BUTTONS_REL')) {
- my $button_rel = $self->get_conf('BUTTONS_REL')->{$direction};
+ if ($self->get_conf('USE_REL_REV')) {
+ my $button_rel = $self->direction_string($direction, 'rel');
if (defined($button_rel) and ($button_rel ne '')) {
$href_attributes .= " rel=\"$button_rel\"";
}
@@ -3458,11 +3443,11 @@ sub _default_format_button($$;$)
if ($self->get_conf('ICONS') and $self->get_conf('ACTIVE_ICONS')
and defined($self->get_conf('ACTIVE_ICONS')->{$button})
and $self->get_conf('ACTIVE_ICONS')->{$button} ne '') {
- my $button_name = $self->get_conf('BUTTONS_NAME')->{$button};
+ my $button_name = $self->direction_string($button, 'button');
$active = &{$self->formatting_function('format_button_icon_img')}($self,
$button_name, $self->get_conf('ACTIVE_ICONS')->{' '});
} else {
- $active = $self->get_conf('BUTTONS_TEXT')->{$button};
+ $active = $self->direction_string($button, 'text');
}
$need_delimiter = 0;
} else {
@@ -3471,28 +3456,26 @@ sub _default_format_button($$;$)
if ($href) {
# button is active
my $btitle = '';
- if ($self->get_conf('BUTTONS_GOTO')
- and defined($self->get_conf('BUTTONS_GOTO')->{$button})) {
- $btitle = ' title="' . $self->get_conf('BUTTONS_GOTO')->{$button} .
'"';
+ my $description = $self->direction_string($button, 'description');
+ if (defined($description)) {
+ $btitle = ' title="' . $description . '"';
}
- if ($self->get_conf('USE_ACCESSKEY')
- and $self->get_conf('BUTTONS_ACCESSKEY')) {
- my $accesskey = $self->get_conf('BUTTONS_ACCESSKEY')->{$button};
+ if ($self->get_conf('USE_ACCESSKEY')) {
+ my $accesskey = $self->direction_string($button, 'accesskey');
if (defined($accesskey) and $accesskey ne '') {
$btitle .= " accesskey=\"$accesskey\"";
}
}
- if ($self->get_conf('USE_REL_REV') and ($self->get_conf('BUTTONS_REL')))
{
- my $button_rel = $self->get_conf('BUTTONS_REL')->{$button};
+ if ($self->get_conf('USE_REL_REV')) {
+ my $button_rel = $self->direction_string($button, 'rel');
if (defined($button_rel) and $button_rel ne '') {
$btitle .= " rel=\"$button_rel\"";
}
}
my $use_icon;
- if ($self->get_conf('ICONS') and $self->get_conf('ACTIVE_ICONS')
- and $self->get_conf('BUTTONS_NAME')) {
+ if ($self->get_conf('ICONS') and $self->get_conf('ACTIVE_ICONS')) {
my $active_icon = $self->get_conf('ACTIVE_ICONS')->{$button};
- my $button_name = $self->get_conf('BUTTONS_NAME')->{$button};
+ my $button_name = $self->direction_string($button, 'button');
if (defined($active_icon) and $active_icon ne ''
and defined($button_name)) {
# use icon
@@ -3506,15 +3489,14 @@ sub _default_format_button($$;$)
if (!$use_icon) {
# use text
$active = '[' . "<a href=\"$href\"${btitle}>".
- $self->get_conf('BUTTONS_TEXT')->{$button}."</a>" . ']';
+ $self->direction_string($button, 'text')."</a>" . ']';
}
} else {
# button is passive
my $use_icon;
- if ($self->get_conf('ICONS') and $self->get_conf('PASSIVE_ICONS')
- and $self->get_conf('BUTTONS_NAME')) {
+ if ($self->get_conf('ICONS') and $self->get_conf('PASSIVE_ICONS')) {
my $passive_icon = $self->get_conf('PASSIVE_ICONS')->{$button};
- my $button_name = $self->get_conf('BUTTONS_NAME')->{$button};
+ my $button_name = $self->direction_string($button, 'button');
if ($passive_icon and $passive_icon ne '') {
$passive = &{$self->formatting_function('format_button_icon_img')}(
$self, $button_name, $passive_icon,
@@ -3523,7 +3505,7 @@ sub _default_format_button($$;$)
}
}
if (!$use_icon) {
- $passive = '[' . $self->get_conf('BUTTONS_TEXT')->{$button} . ']';
+ $passive = '[' . $self->direction_string($button, 'text') . ']';
}
}
$need_delimiter = 0;
@@ -7084,6 +7066,46 @@ sub converter_initialize($)
$conf_default_no_arg_commands_formatting_normal->{'*'}->{'text'}
= $self->{'line_break_element'};
+ # three types of direction strings:
+ # * strings not translated, already converted
+ # * strings translated
+ # - strings already converted
+ # - strings not already converted
+ $self->{'directions_strings'} = {};
+
+ my $customized_direction_strings =
Texinfo::Config::GNUT_get_direction_string_info();
+ foreach my $string_type (keys(%default_converted_directions_strings)) {
+ foreach my $direction
(keys(%{$default_converted_directions_strings{$string_type}})) {
+ my $string = '';
+ if ($customized_direction_strings->{$string_type}
+ and $customized_direction_strings->{$string_type}->{$direction}) {
+ if
(defined($customized_direction_strings->{$string_type}->{$direction}->{'converted'}))
{
+ $string
+ =
$customized_direction_strings->{$string_type}->{$direction}->{'converted'}
+ }
+ } else {
+ $string
+ = $default_converted_directions_strings{$string_type}->{$direction};
+ }
+ $self->{'directions_strings'}->{$string_type}->{$direction}
+ = $self->substitute_html_non_breaking_space($string);
+ }
+ }
+ $self->{'translated_direction_strings'} = {};
+ foreach my $string_type (keys(%default_translated_directions_strings)) {
+ $self->{'translated_direction_strings'}->{$string_type} = {};
+ foreach my $direction
(keys(%{$default_translated_directions_strings{$string_type}})) {
+ if ($customized_direction_strings->{$string_type}
+ and $customized_direction_strings->{$string_type}->{$direction}) {
+ $self->{'translated_direction_strings'}->{$string_type}->{$direction}
+ = $customized_direction_strings->{$string_type}->{$direction};
+ } else {
+ $self->{'translated_direction_strings'}->{$string_type}->{$direction}
+ = $default_translated_directions_strings{$string_type}->{$direction};
+ }
+ }
+ }
+
$self->{'types_conversion'} = {};
my $customized_types_conversion =
Texinfo::Config::GNUT_get_types_conversion();
foreach my $type (keys(%default_types_conversion)) {
@@ -9009,8 +9031,8 @@ sub _get_links($$$$)
my $link_title = '';
$link_title = " title=\"$link_string\"" if (defined($link_string));
my $rel = '';
- $rel = " rel=\"".$self->get_conf('BUTTONS_REL')->{$link}.'"'
- if (defined($self->get_conf('BUTTONS_REL')->{$link}));
+ my $button_rel = $self->direction_string($link, 'rel');
+ $rel = " rel=\"".$button_rel.'"' if (defined($button_rel));
$links .= $self->close_html_lone_element(
"<link href=\"$link_href\"${rel}${link_title}")."\n";
}
@@ -9208,21 +9230,20 @@ EOT
foreach my $button (@{$self->get_conf('SECTION_BUTTONS')}) {
next if ($button eq ' ' or ref($button) eq 'CODE' or ref($button) eq
'SCALAR'
or ref($button) eq 'ARRAY');
- my $button_name = $self->get_conf('BUTTONS_NAME')->{$button};
+ my $button_name = $self->direction_string($button, 'button');
$about .= " <tr>\n ".$self->html_attribute_class('td',
['button-direction-about']) .'>';
$about .=
($self->get_conf('ICONS') && $self->get_conf('ACTIVE_ICONS')->{$button} ?
&{$self->formatting_function('format_button_icon_img')}($self,
$button_name, $self->get_conf('ACTIVE_ICONS')->{$button})
:
- ' [' . $self->get_conf('BUTTONS_TEXT')->{$button} . '] ');
+ ' [' . $self->direction_string($button, 'text') . '] ');
$about .= "</td>\n";
$about .=
' '.$self->html_attribute_class('td', ['name-direction-about']).'>'
.$button_name."</td>
- <td>".$self->get_conf('BUTTONS_GOTO')->{$button}."</td>
- <td>".$self->substitute_html_non_breaking_space(
- $self->get_conf('BUTTONS_EXAMPLE')->{$button})."</td>
+ <td>".$self->direction_string($button, 'description')."</td>
+ <td>".$self->direction_string($button, 'example')."</td>
</tr>
";
}
@@ -9511,6 +9532,12 @@ sub _initialize_output_state($)
$self->{'document_global_context_css'} = {};
$self->{'file_css'} = {};
+ # direction strings
+ foreach my $string_type (keys(%default_translated_directions_strings)) {
+ # those will be determined from translatable strings
+ $self->{'directions_strings'}->{$string_type} = {};
+ };
+
# targets and directions
# used for diverse elements: tree units, indices, footnotes, special
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index 6db016e82c..800006ed7d 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -27,6 +27,7 @@ use strict;
use Encode;
use POSIX qw(setlocale LC_ALL LC_MESSAGES);
+#use Carp qw(confess);
use Locale::Messages;
# note that there is a circular dependency with the parser module, as
@@ -59,6 +60,9 @@ sub _decode_i18n_string($$)
{
my $string = shift;
my $encoding = shift;
+ #if (!defined($encoding)) {
+ # confess("_decode_i18n_string $string undef encoding\n");
+ #}
return Encode::decode($encoding, $string);
}
- 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, 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