mirror of
https://https.git.savannah.gnu.org/git/gettext.git
synced 2026-01-26 15:39:11 +00:00
xgettext: Perl: Recognize strings with embedded expressions.
* gettext-tools/src/x-perl.c (enum token_type_ty, token_ty, struct token_stack_ty): Moved. (struct perl_extractor): New type. (fp, linebuf, linebuf_size, linesize, linepos, eaten_here, end_of_file, last_comment_line, last_non_comment_line, nesting_depth, last_token_type, token_stack): Remove variables. (perl_extractor_init_rest): New function. (phase1_getc): Add a 'struct perl_extractor *' parameter. Read from a string if fp == NULL. (phase1_ungetc, get_here_document, skip_pod, phase2_getc, phase2_ungetc, extract_quotelike_pass1, extract_quotelike_pass1_utf8): Add a 'struct perl_extractor *' parameter. (extract_perl_input): New declaration. (extract_quotelike): Add a 'struct perl_extractor *' parameter. (extract_triple_quotelike): Add a 'struct perl_extractor *' parameter. Remove mlp parameter. (extract_quotelike_pass3): Add a 'struct perl_extractor *' parameter. (extract_variable): Add a 'struct perl_extractor *' parameter. Remove mlp parameter. (interpolate_keywords): Likewise. Rename states wait_quote → seen_lbrace, dquote → lbrace_dquote, squote → lbrace_squote, barekey → lbrace_barekey. Add handling of bracket-enclosed expressions in strings. (x_perl_prelex, x_perl_lex): Add a 'struct perl_extractor *' parameter. Remove mlp parameter. (x_perl_unlex): Add a 'struct perl_extractor *' parameter. (collect_message, extract_balanced): Add a 'struct perl_extractor *' parameter. Remove mlp parameter. (extract_perl_input): New function, extracted from extract_perl. (extract_perl): Use it. Create a 'struct perl_extractor'. * gettext-tools/tests/xgettext-perl-5: Add tests of strings with embedded expressions. * NEWS: Mention the change.
This commit is contained in:
parent
6120a2cd4a
commit
14aa472111
5
NEWS
5
NEWS
@ -26,7 +26,10 @@ Version 0.23 - September 2024
|
||||
- Tcl: With the forthcoming Tcl 9.0, characters outside the Unicode BMP
|
||||
in Tcl message catalogs (.msg files) will work regardless of the locale's
|
||||
encoding.
|
||||
- Perl: xgettext now reports warnings instead of fatal errors.
|
||||
- Perl:
|
||||
o xgettext now reports warnings instead of fatal errors.
|
||||
o Strings with embedded expressions (a.k.a. interpolated strings) are now
|
||||
recognized.
|
||||
- PHP: Strings with embedded expressions are now recognized.
|
||||
|
||||
* Runtime behaviour:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
|
||||
|
||||
# Test Perl support: --add-comments option.
|
||||
# Test Perl support: --add-comments option, strings with embedded expressions.
|
||||
|
||||
cat <<\EOF > xg-pl-5.pl
|
||||
# This comment will not be extracted.
|
||||
@ -13,6 +13,11 @@ print gettext "Hey Jude";
|
||||
# TRANSLATORS:
|
||||
# Nickname of the Beatles
|
||||
print gettext "The Fabulous Four";
|
||||
# Strings with embedded expressions, a.k.a. interpolated strings.
|
||||
print gettext "embedded_1_$foo bar";
|
||||
print gettext "embedded_2_${foo}bar";
|
||||
print gettext "embedded_3_$array[func(gettext 'embedded_3_sub1')]_bar_$array[func(gettext 'embedded_3_sub2')]_baz";
|
||||
print gettext "embedded_4";
|
||||
EOF
|
||||
|
||||
: ${XGETTEXT=xgettext}
|
||||
@ -35,6 +40,15 @@ msgstr ""
|
||||
#. Nickname of the Beatles
|
||||
msgid "The Fabulous Four"
|
||||
msgstr ""
|
||||
|
||||
msgid "embedded_3_sub1"
|
||||
msgstr ""
|
||||
|
||||
msgid "embedded_3_sub2"
|
||||
msgstr ""
|
||||
|
||||
msgid "embedded_4"
|
||||
msgstr ""
|
||||
EOF
|
||||
|
||||
: ${DIFF=diff}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user