[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Change customization of translations to target on
From: |
Patrice Dumas |
Subject: |
branch master updated: Change customization of translations to target only translated string |
Date: |
Sun, 05 Nov 2023 09:26:53 -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 505734b040 Change customization of translations to target only
translated string
505734b040 is described below
commit 505734b040fb3e348a7bb4ce33fefefc28be61ce
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 5 15:26:43 2023 +0100
Change customization of translations to target only translated string
* tp/Texinfo/Translations.pm (translate_string): rename _gdt as
translate_string. Update callers.
* doc/texi2any_api.texi (Translated Strings Customization)
(Translation Contexts), tp/Texinfo/Convert/HTML.pm (translate_string),
(%default_formatting_references), tp/Texinfo/Translations.pm (gdt)
(gdt_string), tp/Texinfo/XS/convert/convert_html.c
(html_translate_string, html_gdt, html_gdt_tree, html_pgdt_tree)
(special_unit_info_tree, html_translate_names)
(convert_to_html_internal), tp/Texinfo/XS/main/call_perl_function.c
(call_formatting_function_format_translate_message),
tp/Texinfo/XS/main/get_perl_info.c, tp/init/documentation_examples.pm,
tp/t/init/special_element_customization.pm,
tp/t/init/translated_strings_customization.pm,
tp/t/init/translation_in_parser_in_translation.pm: remove the
possibility to customize the output of gdt or gdt_string, instead
replace translate_string by the format_translate_message formatting
function output. format_translate_message replaces
format_translate_message_tree and format_translate_message_string.
---
ChangeLog | 24 +++++
doc/texi2any_api.texi | 62 +++++--------
tp/TODO | 4 -
tp/Texinfo/Convert/HTML.pm | 41 ++-------
tp/Texinfo/Translations.pm | 24 +++--
tp/Texinfo/XS/convert/convert_html.c | 102 +++++++++++++++++-----
tp/Texinfo/XS/main/call_perl_function.c | 16 +---
tp/Texinfo/XS/main/call_perl_function.h | 3 +-
tp/Texinfo/XS/main/converter_types.h | 7 +-
tp/Texinfo/XS/main/get_perl_info.c | 6 +-
tp/Texinfo/XS/main/translations.h | 7 ++
tp/init/documentation_examples.pm | 29 ++----
tp/t/init/special_element_customization.pm | 11 ++-
tp/t/init/translated_strings_customization.pm | 28 ++----
tp/t/init/translation_in_parser_in_translation.pm | 11 ++-
15 files changed, 190 insertions(+), 185 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 803281b6db..bc39e47fd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2023-11-05 Patrice Dumas <pertusus@free.fr>
+
+ Change customization of translations to target only translated string
+
+ * tp/Texinfo/Translations.pm (translate_string): rename _gdt as
+ translate_string. Update callers.
+
+ * doc/texi2any_api.texi (Translated Strings Customization)
+ (Translation Contexts), tp/Texinfo/Convert/HTML.pm (translate_string),
+ (%default_formatting_references), tp/Texinfo/Translations.pm (gdt)
+ (gdt_string), tp/Texinfo/XS/convert/convert_html.c
+ (html_translate_string, html_gdt, html_gdt_tree, html_pgdt_tree)
+ (special_unit_info_tree, html_translate_names)
+ (convert_to_html_internal), tp/Texinfo/XS/main/call_perl_function.c
+ (call_formatting_function_format_translate_message),
+ tp/Texinfo/XS/main/get_perl_info.c, tp/init/documentation_examples.pm,
+ tp/t/init/special_element_customization.pm,
+ tp/t/init/translated_strings_customization.pm,
+ tp/t/init/translation_in_parser_in_translation.pm: remove the
+ possibility to customize the output of gdt or gdt_string, instead
+ replace translate_string by the format_translate_message formatting
+ function output. format_translate_message replaces
+ format_translate_message_tree and format_translate_message_string.
+
2023-11-05 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm,
diff --git a/doc/texi2any_api.texi b/doc/texi2any_api.texi
index 3202da582e..382769bebc 100644
--- a/doc/texi2any_api.texi
+++ b/doc/texi2any_api.texi
@@ -3167,49 +3167,31 @@ translation context associated.
@node Translated Strings Customization
@section Translated Strings Customization
-To customize strings translations, register the
-@code{format_translate_message_tree} and/or
-@code{format_translate_message_string} function references:
-
-@deftypefn {Function Reference} @var{$translated_tree}
format_translate_message_tree @
- (@var{$converter}, @var{$string}, @var{$lang}, @var{\%variables_hash}, @
- @var{$translation_context})
-@deftypefnx {Function Reference} @var{$translated_string}
format_translate_message_string @
- (@var{$converter}, @var{$string}, @var{$lang}, @var{\%variables_hash}, @
- @var{$translation_context})
+To customize strings translations, register the @code{format_translate_message}
+function reference:
+
+@deftypefn {Function Reference} @var{$translated_string}
format_translate_message @
+ (@var{$converter}, @var{$string}, @var{$lang}, @var{$translation_context})
@var{$string} is the string to be translated, @var{$lang} is the language.
@var{$translation_context} is an optional translation context.
-The result returned should be a perl Texinfo tree for
-@code{format_translate_message_tree} (replacing @code{gdt} and
-@code{pgdt}), and a string for @code{format_translate_message_string}
-(replacing @code{gdt_string}). The result returned may also be @samp{undef},
-in which case the translation is done as if the function reference had not been
-defined.
+The result returned should be the translated string. The result returned may
+also be @samp{undef}, in which case the translation is done as if the function
+reference had not been defined.
@xref{Internationalization of Strings Function} for more information on
strings translations function arguments.
-
-The @code{replace_convert_substrings} method of @code{Texinfo::Translations}
-can be used to substitute @var{\%variables_hash} and return a Texinfo tree
-based on a translated string
-(@pxref{Texinfo@asis{::}Translations $tree =
$object->replace_convert_substrings($translated_string@comma{}
$replaced_substrings),,
-Texinfo@asis{::}Translations replace_convert_substrings, texi2any_internals}).
-The @code{replace_substrings} method of @code{Texinfo::Translations}
-can be used to substitute @var{\%variables_hash} and return a string
-based on a translated string
-(@pxref{Texinfo@asis{::}Translations $string =
$object->replace_substrings($translated_string@comma{} $replaced_substrings),,
-Texinfo@asis{::}Translations replace_substrings, texi2any_internals}).
@end deftypefn
This function reference is not set in the default case, in the default case
-the @code{gdt} and @code{gdt_string} methods from the
-@code{Texinfo::Translations} module are called (@pxref{Internationalization of
-Strings Function}). @xref{Specific formating Functions} for information on how
-to register and get the function reference.
+@code{translate_string} from the @code{Texinfo::Translations} module is
+called (@pxref{Internationalization of Strings Function}).
+@xref{Specific formating Functions} for information on how to register and get
+the function reference.
+@anchor{New translated strings example}
Here is an example with new translated strings added and definition
-of @code{format_translate_message_string} to translate the strings:
+of @code{format_translate_message} to translate the strings:
@example
texinfo_register_no_arg_command_formatting('error', undef, undef,
@@ -3226,10 +3208,9 @@ my %translations = (
# @dots{}
);
-sub my_format_translate_message_string($$$;$$)
+sub my_format_translate_message($$$;$)
@{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @@_;
+ my ($self, $string, $lang, $translation_context) = @@_;
$translation_context = '' if (!defined($translation_context));
if (exists($translations@{$lang@})
and exists($translations@{$lang@}->@{$string@})
@@ -3237,14 +3218,13 @@ sub my_format_translate_message_string($$$;$$)
->@{$translation_context@})) @{
my $translation = $translations@{$lang@}->@{$string@}
->@{$translation_context@};
- return $self->replace_substrings($translation,
- $replaced_substrings);
+ return $translation;
@}
return undef;
@}
-texinfo_register_formatting_function('format_translate_message_string',
- \&my_format_translate_message_string);
+texinfo_register_formatting_function('format_translate_message',
+ \&my_format_translate_message);
@end example
@@ -3287,8 +3267,8 @@ Units Varieties}). For example, the @code{footnotes}
special output unit
variety heading translation context is @samp{footnotes section heading}.
Here is an example, which could be used with a similar
-function registered as in the example above, but using
-@code{format_translate_message_tree}:
+function registered as in the example above
+(@pxref{New translated strings example}):
@example
texinfo_register_direction_string_info('Forward', 'text', undef,
diff --git a/tp/TODO b/tp/TODO
index 11b1d38707..e05e39ea56 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -13,10 +13,6 @@ Before next release
check $(native_tools) variable in Makefile.am does not seems to be
set and seems useless.
-Check format_translate_message_tree api after the changes in gdt api
-when the translation of HTML to C is advnaced enough that it becomes clear
-that the API won't change again.
-
For unicode sorting in C for index sorting, strcoll_l or even better strxfrm_l
could be used, it sorts according to a locale specified in argument. However,
it does not seems to be that portable, there is no associated gnulib
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index aa382b1b2f..a9c664dde9 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2439,46 +2439,24 @@ sub _translate_names($)
# redefined functions
#
-# Texinfo::Translations::gdt redefined to call user defined function.
-sub gdt($$;$$$)
+# Texinfo::Translations::translate_string redefined to call user defined
function.
+sub translate_string($$;$$)
{
- my ($self, $message, $replaced_substrings, $message_context, $lang) = @_;
- if
(defined($self->{'formatting_function'}->{'format_translate_message_tree'})) {
- my $format_lang = $lang;
- $format_lang = $self->get_conf('documentlanguage')
- if ($self and !defined($format_lang));
- my $result_tree
- =
&{$self->{'formatting_function'}->{'format_translate_message_tree'}}($self,
- $message, $format_lang, $replaced_substrings,
- $message_context);
- if (defined($result_tree)) {
- return $result_tree;
- }
- }
- return $self->SUPER::gdt($message, $replaced_substrings, $message_context,
- $lang);
-}
-
-# Texinfo::Translations::gdt_string redefined to call user defined function.
-sub gdt_string($$;$$$)
-{
- my ($self, $message, $replaced_substrings, $message_context, $lang) = @_;
- if
(defined($self->{'formatting_function'}->{'format_translate_message_string'})) {
+ my ($self, $string, $translation_context, $lang) = @_;
+ if (defined($self->{'formatting_function'}->{'format_translate_message'})) {
my $format_lang = $lang;
$format_lang = $self->get_conf('documentlanguage')
if ($self and !defined($format_lang));
my $translated_string
- =
&{$self->{'formatting_function'}->{'format_translate_message_string'}}($self,
- $message, $format_lang, $replaced_substrings,
- $message_context);
+ = &{$self->{'formatting_function'}->{'format_translate_message'}}($self,
+ $string, $format_lang, $translation_context);
if (defined($translated_string)) {
return $translated_string;
}
}
- return $self->SUPER::gdt_string($message, $replaced_substrings,
$message_context,
- $lang);
-}
+ return $self->SUPER::translate_string($string, $translation_context, $lang);
+}
sub converter_defaults($$)
{
@@ -7643,8 +7621,7 @@ foreach my $customized_reference
('external_target_split_name',
'format_separate_anchor' => \&_default_format_separate_anchor,
'format_titlepage' => \&_default_format_titlepage,
'format_title_titlepage' => \&_default_format_title_titlepage,
- 'format_translate_message_tree' => undef,
- 'format_translate_message_string' => undef,
+ 'format_translate_message' => undef,
);
# not up for customization
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index 0d4840261f..f976f7dacb 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -149,7 +149,7 @@ sub _switch_messages_locale
# is encountered. Some set some default based on @documentlanguage if in
# the preamble, some set some default language (in general en) in any
# case.
-sub _gdt($$;$$)
+sub translate_string($$;$$)
{
my ($customization_information, $string, $translation_context, $lang) = @_;
if (ref($customization_information) eq 'Texinfo::Document') {
@@ -290,8 +290,15 @@ sub gdt($$;$$$)
my ($customization_information, $string, $replaced_substrings,
$translation_context, $lang) = @_;
- my $translated_string = _gdt($customization_information, $string,
- $translation_context, $lang);
+ # allows to redefine translate_string, as done in the HTML converter. Cannot
+ # directly call translate_string on $customization_information, as it may not
+ # provide the method if it does not inherit from Texinfo::Translations, as is
+ # the case for Texinfo::Parser.
+ my $translate_string_method
+ = $customization_information->can('translate_string');
+ $translate_string_method = \&translate_string if (!$translate_string_method);
+ my $translated_string = &$translate_string_method($customization_information,
+ $string, $translation_context, $lang);
my $result_tree = replace_convert_substrings($customization_information,
$translated_string,
@@ -306,8 +313,15 @@ sub gdt_string($$;$$$)
my ($customization_information, $string, $replaced_substrings,
$translation_context, $lang) = @_;
- my $translated_string = _gdt($customization_information, $string,
- $translation_context, $lang);
+ # allows to redefine translate_string, as done in the HTML converter. Cannot
+ # directly call translate_string on $customization_information, as it may not
+ # provide the method if it does not inherit from Texinfo::Translations, as is
+ # the case for Texinfo::Parser.
+ my $translate_string_method
+ = $customization_information->can('translate_string');
+ $translate_string_method = \&translate_string if (!$translate_string_method);
+ my $translated_string = &$translate_string_method($customization_information,
+ $string, $translation_context, $lang);
return replace_substrings ($customization_information, $translated_string,
$replaced_substrings);
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 4d94cc6a4e..2f2f955049 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -39,6 +39,8 @@
#include "translations.h"
#include "convert_utils.h"
#include "call_perl_function.h"
+/* for TREE_AND_STRINGS */
+#include "document.h"
#include "convert_html.h"
@@ -307,24 +309,13 @@ find_element_target (HTML_TARGET_LIST *targets, ELEMENT
*element)
return 0;
}
-ELEMENT *
-html_gdt_tree (const char *string, DOCUMENT *document, OPTIONS *options,
- NAMED_STRING_ELEMENT_LIST *replaced_substrings,
- const char *translation_context,
- const char *in_lang)
-{
- return gdt_tree (string, document, options, replaced_substrings,
- translation_context, in_lang);
-}
-
char *
-html_gdt_string (const char *string, CONVERTER *self,
- NAMED_STRING_ELEMENT_LIST *replaced_substrings,
- const char *translation_context, const char *in_lang)
+html_translate_string (CONVERTER *self, const char *string,
+ const char *translation_context, const char *in_lang)
{
FORMATTING_REFERENCE *formatting_reference
- = &self->formatting_references[FR_format_translate_message_string];
+ = &self->formatting_references[FR_format_translate_message];
/* there is no place where FRS_status_ignore could be set, but
it does not hurt to consider it possible */
@@ -339,24 +330,89 @@ html_gdt_string (const char *string, CONVERTER *self,
lang = self->conf->documentlanguage;
translated_string
- = call_formatting_function_format_translate_message_string(
- self, string, lang, replaced_substrings, translation_context);
+ = call_formatting_function_format_translate_message(
+ self, string, lang, translation_context);
if (translated_string)
return translated_string;
}
- return gdt_string (string, self->conf, replaced_substrings,
- translation_context, in_lang);
+ return translate_string (self->conf, string, translation_context,
+ in_lang);
+}
+
+/* returns a document descriptor. */
+int
+html_gdt (const char *string, CONVERTER *self,
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+ const char *translation_context, const char *in_lang)
+{
+ char *translated_string = html_translate_string (self, string,
+ translation_context,
+ in_lang);
+
+ int document_descriptor
+ = replace_convert_substrings (translated_string, replaced_substrings);
+ free (translated_string);
+ return document_descriptor;
+}
+
+/* a copy and paste of translations.c gdt_tree with html_gdt instead of gdt */
+ELEMENT *
+html_gdt_tree (const char *string, DOCUMENT *document, CONVERTER *self,
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+ const char *translation_context,
+ const char *in_lang)
+{
+ ELEMENT *tree;
+ int gdt_document_descriptor = html_gdt (string, self, replaced_substrings,
+ translation_context, in_lang);
+ TREE_AND_STRINGS *tree_and_strings
+ = unregister_document_descriptor_tree (gdt_document_descriptor);
+
+ tree = tree_and_strings->tree;
+
+ if (tree_and_strings->small_strings)
+ {
+ /* this is very unlikely, as small strings correspond to file names and
+ macro names, while we are parsing a simple string */
+ if (tree_and_strings->small_strings->number)
+ {
+ if (document)
+ merge_strings (document->small_strings,
+ tree_and_strings->small_strings);
+ else
+ fatal ("html_gdt_tree no document but small_strings");
+ }
+ free (tree_and_strings->small_strings->list);
+ free (tree_and_strings->small_strings);
+ }
+ free (tree_and_strings);
+
+ return tree;
+}
+
+char *
+html_gdt_string (const char *string, CONVERTER *self,
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings,
+ const char *translation_context, const char *in_lang)
+{
+ /* FIXME */
+ char *translated_string = html_translate_string (self, string,
+ translation_context, in_lang);
+
+ char *result = replace_substrings (translated_string, replaced_substrings);
+ free (translated_string);
+ return result;
}
ELEMENT *
html_pgdt_tree (const char *translation_context, const char *string,
- DOCUMENT *document, OPTIONS *options,
+ DOCUMENT *document, CONVERTER *self,
NAMED_STRING_ELEMENT_LIST *replaced_substrings,
const char *in_lang)
{
- return html_gdt_tree (string, document, options, replaced_substrings,
+ return html_gdt_tree (string, document, self, replaced_substrings,
translation_context, in_lang);
}
@@ -386,7 +442,7 @@ special_unit_info_tree (CONVERTER *self, enum
special_unit_info_tree type,
special_unit_variety);
self->special_unit_info_tree[type][i]
= html_pgdt_tree (translation_context, special_unit_info_string,
- self->document, self->conf, 0, 0);
+ self->document, self, 0, 0);
free (translation_context);
return self->special_unit_info_tree[type][i];
}
@@ -2733,7 +2789,7 @@ html_translate_names (CONVERTER *self)
{/* FIXME use document associated to converter? */
translated_tree =
html_gdt_tree (format_spec->translated_to_convert,
- 0, self->conf, 0, 0, 0);
+ 0, self, 0, 0, 0);
}
else
translated_tree = translated_command_tree (self, cmd);
@@ -2899,7 +2955,7 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
char *translation_context
= lookup_extra_string (element, "translation_context");
ELEMENT *translated = html_gdt_tree (element->text.text,
self->document,
- self->conf, 0, translation_context, 0);
+ self, 0, translation_context, 0);
convert_to_html_internal (self, translated, &text_result,
"translated TEXT");
diff --git a/tp/Texinfo/XS/main/call_perl_function.c
b/tp/Texinfo/XS/main/call_perl_function.c
index 6fb59090bd..9ba5be1673 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -723,9 +723,8 @@ call_formatting_function_format_begin_file (CONVERTER
*self, char *filename,
}
char *
-call_formatting_function_format_translate_message_string (CONVERTER *self,
+call_formatting_function_format_translate_message (CONVERTER *self,
const char *message, const char *lang,
- NAMED_STRING_ELEMENT_LIST *replaced_substrings,
const char *message_context)
{
int count;
@@ -734,7 +733,6 @@ call_formatting_function_format_translate_message_string
(CONVERTER *self,
STRLEN len;
SV *result_sv;
SV *formatting_reference_sv;
- SV *replaced_substrings_sv;
dTHX;
@@ -743,7 +741,7 @@ call_formatting_function_format_translate_message_string
(CONVERTER *self,
formatting_reference_sv
= self->formatting_references[
- FR_format_translate_message_string].sv_reference;
+ FR_format_translate_message].sv_reference;
if (self->modified_state)
{
@@ -751,23 +749,17 @@ call_formatting_function_format_translate_message_string
(CONVERTER *self,
self->modified_state = 0;
}
- if (replaced_substrings)
- replaced_substrings_sv = build_replaced_substrings (replaced_substrings);
- else
- replaced_substrings_sv = newSV (0);
-
dSP;
ENTER;
SAVETMPS;
PUSHMARK(SP);
- EXTEND(SP, 5);
+ EXTEND(SP, 4);
PUSHs(sv_2mortal (newRV_inc (self->hv)));
PUSHs(sv_2mortal (newSVpv_utf8 (message, 0)));
PUSHs(sv_2mortal (newSVpv (lang, 0)));
- PUSHs(sv_2mortal (replaced_substrings_sv));
PUSHs(sv_2mortal (newSVpv_utf8 (message_context, 0)));
PUTBACK;
@@ -777,7 +769,7 @@ call_formatting_function_format_translate_message_string
(CONVERTER *self,
SPAGAIN;
if (count != 1)
- croak("format_translate_message_string should return 1 item\n");
+ croak("format_translate_message should return 1 item\n");
result_sv = POPs;
if (SvOK (result_sv))
diff --git a/tp/Texinfo/XS/main/call_perl_function.h
b/tp/Texinfo/XS/main/call_perl_function.h
index d340134933..5447019d9b 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -60,9 +60,8 @@ char *call_commands_open (CONVERTER *self, enum command_id
cmd,
char *call_output_units_conversion (CONVERTER *self,
enum output_unit_type unit_type,
OUTPUT_UNIT *output_unit, const char *content);
-char *call_formatting_function_format_translate_message_string (CONVERTER
*self,
+char *call_formatting_function_format_translate_message (CONVERTER *self,
const char *message, const char *lang,
- NAMED_STRING_ELEMENT_LIST *replaced_substrings,
const char *message_context);
#endif
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 40b7d4ced7..c2f59efb0c 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -112,8 +112,7 @@ enum direction_string {
html_fr_reference(format_separate_anchor) \
html_fr_reference(format_titlepage) \
html_fr_reference(format_title_titlepage) \
- html_fr_reference(format_translate_message_tree) \
- html_fr_reference(format_translate_message_string) \
+ html_fr_reference(format_translate_message)
enum html_formatting_reference {
#define html_fr_reference(name) FR_## name,
@@ -413,9 +412,9 @@ typedef struct CONVERTER {
int code_types[ET_special_unit_element+1];
char *pre_class_types[ET_special_unit_element+1];
FORMATTING_REFERENCE
- formatting_references[FR_format_translate_message_string+1];
+ formatting_references[FR_format_translate_message+1];
FORMATTING_REFERENCE
- css_string_formatting_references[FR_format_translate_message_string+1];
+ css_string_formatting_references[FR_format_translate_message+1];
FORMATTING_REFERENCE commands_open[BUILTIN_CMD_NUMBER];
FORMATTING_REFERENCE commands_conversion[BUILTIN_CMD_NUMBER];
FORMATTING_REFERENCE css_string_commands_conversion[BUILTIN_CMD_NUMBER];
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index a996c22ae2..d1ceb3d4b9 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -556,7 +556,7 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
/* no need to check if it exists */
formatting_function_hv = (HV *)SvRV (*formatting_function_sv);
- for (i = 0; i < FR_format_translate_message_string+1; i++)
+ for (i = 0; i < FR_format_translate_message+1; i++)
{
char *ref_name = html_formatting_reference_names[i];
FORMATTING_REFERENCE *formatting_reference
@@ -591,9 +591,9 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
specific references */
memcpy (&converter->css_string_formatting_references,
&converter->formatting_references,
- (FR_format_translate_message_string+1) * sizeof (FORMATTING_REFERENCE));
+ (FR_format_translate_message+1) * sizeof (FORMATTING_REFERENCE));
- for (i = 0; i < FR_format_translate_message_string+1; i++)
+ for (i = 0; i < FR_format_translate_message+1; i++)
{
char *ref_name = html_formatting_reference_names[i];
SV **default_formatting_reference_sv
diff --git a/tp/Texinfo/XS/main/translations.h
b/tp/Texinfo/XS/main/translations.h
index f38f7d1f3e..595b72b3f2 100644
--- a/tp/Texinfo/XS/main/translations.h
+++ b/tp/Texinfo/XS/main/translations.h
@@ -21,6 +21,13 @@ typedef struct NAMED_STRING_ELEMENT_LIST {
NAMED_STRING_ELEMENT *list;
} NAMED_STRING_ELEMENT_LIST;
+char *translate_string (OPTIONS *options, const char * string,
+ const char *translation_context, const char *in_lang);
+int replace_convert_substrings (char *translated_string,
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings);
+char *replace_substrings (char *string,
+ NAMED_STRING_ELEMENT_LIST *replaced_substrings);
+
int gdt (const char * string, OPTIONS *options,
NAMED_STRING_ELEMENT_LIST *replaced_substrings,
const char *translation_context,
diff --git a/tp/init/documentation_examples.pm
b/tp/init/documentation_examples.pm
index 4bb590d37c..77a9d5b34a 100644
--- a/tp/init/documentation_examples.pm
+++ b/tp/init/documentation_examples.pm
@@ -155,39 +155,20 @@ sub my_label_target_name($$$$) {
texinfo_register_file_id_setting_function('label_target_name',
\&my_label_target_name);
-sub my_format_translate_message_tree($$$;$$)
+sub my_format_translate_message($$$;$)
{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @_;
+ my ($self, $string, $lang, $translation_context) = @_;
$translation_context = '' if (!defined($translation_context));
if (exists($translations{$lang})
and exists($translations{$lang}->{$string})
and exists($translations{$lang}->{$string}->{$translation_context})) {
my $translation = $translations{$lang}->{$string}->{$translation_context};
- return $self->replace_convert_substrings($translation,
- $replaced_substrings);
+ return $translation;
}
return undef;
}
-texinfo_register_formatting_function('format_translate_message_tree',
- \&my_format_translate_message_tree);
+texinfo_register_formatting_function('format_translate_message',
+ \&my_format_translate_message);
-sub my_format_translate_message_string($$$;$$)
-{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @_;
- $translation_context = '' if (!defined($translation_context));
- if (exists($translations{$lang})
- and exists($translations{$lang}->{$string})
- and exists($translations{$lang}->{$string}->{$translation_context})) {
- my $translation = $translations{$lang}->{$string}->{$translation_context};
- return $self->replace_substrings($translation,
- $replaced_substrings);
- }
- return undef;
-}
-
-texinfo_register_formatting_function('format_translate_message_string',
-
\&my_format_translate_message_string);
1;
diff --git a/tp/t/init/special_element_customization.pm
b/tp/t/init/special_element_customization.pm
index c464879fb9..17283ae706 100644
--- a/tp/t/init/special_element_customization.pm
+++ b/tp/t/init/special_element_customization.pm
@@ -34,22 +34,21 @@ my %translations = (
);
-sub _texi2any_tests_special_unit_translate_message_tree($$$;$$)
+sub _texi2any_tests_special_unit_translate_message($$$;$)
{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @_;
+ my ($self, $string, $lang, $translation_context) = @_;
$translation_context = '' if (!defined($translation_context));
if (exists($translations{$lang})
and exists($translations{$lang}->{$string})
and exists($translations{$lang}->{$string}->{$translation_context})) {
my $translation = $translations{$lang}->{$string}->{$translation_context};
- return $self->replace_convert_substrings($translation,
$replaced_substrings);
+ return $translation;
}
return undef;
}
-texinfo_register_formatting_function('format_translate_message_tree',
- \&_texi2any_tests_special_unit_translate_message_tree);
+texinfo_register_formatting_function('format_translate_message',
+ \&_texi2any_tests_special_unit_translate_message);
# avoid doing twice if there are more than one manual processed
my $button_added;
diff --git a/tp/t/init/translated_strings_customization.pm
b/tp/t/init/translated_strings_customization.pm
index 79c1c44773..f152deca29 100644
--- a/tp/t/init/translated_strings_customization.pm
+++ b/tp/t/init/translated_strings_customization.pm
@@ -38,39 +38,21 @@ my %translations = (
},
);
-sub _texi2any_tests_format_translate_message_tree($$$;$$)
+sub _texi2any_tests_format_translate_message($$$;$)
{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @_;
+ my ($self, $string, $lang, $translation_context) = @_;
$translation_context = '' if (!defined($translation_context));
if (exists($translations{$lang})
and exists($translations{$lang}->{$string})
and exists($translations{$lang}->{$string}->{$translation_context})) {
my $translation = $translations{$lang}->{$string}->{$translation_context};
- return $self->replace_convert_substrings($translation,
$replaced_substrings);
+ return $translation;
}
return undef;
}
-texinfo_register_formatting_function('format_translate_message_tree',
- \&_texi2any_tests_format_translate_message_tree);
-
-sub _texi2any_tests_format_translate_message_string($$$;$$)
-{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @_;
- $translation_context = '' if (!defined($translation_context));
- if (exists($translations{$lang})
- and exists($translations{$lang}->{$string})
- and exists($translations{$lang}->{$string}->{$translation_context})) {
- my $translation = $translations{$lang}->{$string}->{$translation_context};
- return $self->replace_substrings($translation, $replaced_substrings);
- }
- return undef;
-}
-
-texinfo_register_formatting_function('format_translate_message_string',
- \&_texi2any_tests_format_translate_message_string);
+texinfo_register_formatting_function('format_translate_message',
+ \&_texi2any_tests_format_translate_message);
# avoid doing twice if there are more than one manual processed
my $button_added;
diff --git a/tp/t/init/translation_in_parser_in_translation.pm
b/tp/t/init/translation_in_parser_in_translation.pm
index ce860554ae..c7d18739fd 100644
--- a/tp/t/init/translation_in_parser_in_translation.pm
+++ b/tp/t/init/translation_in_parser_in_translation.pm
@@ -39,23 +39,22 @@ DD
'},
});
-sub _texi2any_test_translation_in_parser_format_translate_message_tree($$$;$$)
+sub _texi2any_test_translation_in_parser_format_translate_message($$$;$)
{
- my ($self, $string, $lang, $replaced_substrings,
- $translation_context) = @_;
+ my ($self, $string, $lang, $translation_context) = @_;
$translation_context = '' if (!defined($translation_context));
if (exists($translations{$lang})
and exists($translations{$lang}->{$string})
and exists($translations{$lang}->{$string}->{$translation_context})) {
my $translation = $translations{$lang}->{$string}->{$translation_context};
- return $self->replace_convert_substrings($translation,
$replaced_substrings);
+ return $translation;
}
return undef;
}
-texinfo_register_formatting_function('format_translate_message_tree',
- \&_texi2any_test_translation_in_parser_format_translate_message_tree);
+texinfo_register_formatting_function('format_translate_message',
+ \&_texi2any_test_translation_in_parser_format_translate_message);
# there are no indices id output for the @def* commands used in Next
# button translation, as their index information is with the tree used
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Change customization of translations to target only translated string,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm, tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use main XS file first, and add use Texinfo::XSLoader if used in the module.
- Next by Date:
branch master updated: Revert documentlanguage fix
- Previous by thread:
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm, tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use main XS file first, and add use Texinfo::XSLoader if used in the module.
- Next by thread:
branch master updated: Revert documentlanguage fix
- Index(es):