From: Bruno Haible Date: Fri, 1 Aug 2003 20:47:21 +0000 (+0000) Subject: Use braces, not brackets, in Perl format strings. X-Git-Tag: v0.13~381 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96b799430a59f93deff8606b97567439027392fa;p=thirdparty%2Fgettext.git Use braces, not brackets, in Perl format strings. --- diff --git a/gettext-tools/doc/ChangeLog b/gettext-tools/doc/ChangeLog index 5865c2430..9cac878cb 100644 --- a/gettext-tools/doc/ChangeLog +++ b/gettext-tools/doc/ChangeLog @@ -1,3 +1,9 @@ +2003-07-05 Bruno Haible + + * gettext.texi (perl-format): Use braces, not brackets, in format + strings. + (Perl pitfalls): Likewise. + 2003-07-03 Bruno Haible * gettext.texi (PHP): Mention plural form functions. diff --git a/gettext-tools/doc/gettext.texi b/gettext-tools/doc/gettext.texi index 7dfcecb49..9e0fa748a 100644 --- a/gettext-tools/doc/gettext.texi +++ b/gettext-tools/doc/gettext.texi @@ -7335,15 +7335,15 @@ Tcl format strings are described in the @file{format.n} manual page, There are two kinds format strings in Perl: those acceptable to the Perl built-in function @code{printf}, labelled as @samp{perl-format}, and those acceptable to the @code{libintl-perl} function @code{__x}, -labelled as @samp{perl-bracket-format}. +labelled as @samp{perl-brace-format}. Perl @code{printf} format strings are described in the @code{sprintf} section of @samp{man perlfunc}. -Perl bracketed format strings are described in the +Perl brace format strings are described in the @file{Locale::TextDomain(3pm)} manual page of the CPAN package libintl-perl. In brief, Perl format uses placeholders put between -brackets (@samp{[} and @samp{]}). The placeholder must have the syntax +braces (@samp{@{} and @samp{@}}). The placeholder must have the syntax of simple identifiers. @node php-format, , perl-format, Translators for other Languages @@ -9019,22 +9019,22 @@ Maybe some of these missing features will be implemented in future versions, but since you can always make do without them at minimal effort, these todos have very low priority. -A nasty problem are bracketed format strings that already contain brackets +A nasty problem are brace format strings that already contain braces as part of the normal text, for example the usage strings typically encountered in programs: @example -die "usage: $0 [OPTIONS] FILENAME...\n"; +die "usage: $0 @{OPTIONS@} FILENAME...\n"; @end example -If you want to internationalize this code with Perl bracketed format strings, +If you want to internationalize this code with Perl brace format strings, you will run into a problem: @example -die __x ("usage: [program] [OPTIONS] FILENAME...\n", program => $0); +die __x ("usage: @{program@} @{OPTIONS@} FILENAME...\n", program => $0); @end example -Whereas @code{@samp{[program]}} is a placeholder, @code{@samp{[OPTIONS]}} +Whereas @samp{@{program@}} is a placeholder, @samp{@{OPTIONS@}} is not and should probably be translated. Yet, there is no way to teach the Perl parser in @code{xgettext} to recognize the first one, and leave the other one alone. @@ -9043,26 +9043,26 @@ There are two possible work-arounds for this problem. If you are sure that your program will run under Perl 5.8.0 or newer (these Perl versions handle positional parameters in @code{printf()}) or if you are sure that the translator will not have to reorder the arguments -in her translation -- for example if you have only one bracketed placeholder +in her translation -- for example if you have only one brace placeholder in your string, or if it describes a syntax, like in this one --, you can -mark the string as @code{no-perl-bracket-format} and use @code{printf()}: +mark the string as @code{no-perl-brace-format} and use @code{printf()}: @example -# xgettext: no-perl-bracket-format -die sprintf ("usage: %s [OPTIONS] FILENAME...\n", $0); +# xgettext: no-perl-brace-format +die sprintf ("usage: %s @{OPTIONS@} FILENAME...\n", $0); @end example -If you want to use the more portable Perl bracket format, you will have to do -put placeholders in place of the literal brackets: +If you want to use the more portable Perl brace format, you will have to do +put placeholders in place of the literal braces: @example -die __x ("usage: [program] [@{]OPTIONS[@}] FILENAME...\n", - program => $0, '@{' => '[', '@}' => ']'); +die __x ("usage: @{program@} @{[@}OPTIONS@{]@} FILENAME...\n", + program => $0, '[' => '@{', ']' => '@}'); @end example -Perl bracketed format strings know no escaping mechanism. No matter how this +Perl brace format strings know no escaping mechanism. No matter how this escaping mechanism looked like, it would either give the programmer a -hard time, make translating Perl bracketed format strings heavy-going, or +hard time, make translating Perl brace format strings heavy-going, or result in a performance penalty at runtime, when the format directives get executed. Most of the time you will happily get along with @code{printf()} for this special case. diff --git a/gettext-tools/po/ChangeLog b/gettext-tools/po/ChangeLog index 27ab66828..c2ba01bb2 100644 --- a/gettext-tools/po/ChangeLog +++ b/gettext-tools/po/ChangeLog @@ -1,3 +1,7 @@ +2003-07-05 Bruno Haible + + * POTFILES.in: Add format-perl-brace.c, remove format-perl-bracket.c. + 2003-07-31 Bruno Haible * ca.po: Update from Ivan Vilata i Balaguer . diff --git a/gettext-tools/po/POTFILES.in b/gettext-tools/po/POTFILES.in index debafb403..f94c65d37 100644 --- a/gettext-tools/po/POTFILES.in +++ b/gettext-tools/po/POTFILES.in @@ -33,7 +33,7 @@ src/format-librep.c src/format-lisp.c src/format-pascal.c src/format-perl.c -src/format-perl-bracket.c +src/format-perl-brace.c src/format-php.c src/format-python.c src/format-tcl.c diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 398506dd3..bef7b140a 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,24 @@ +2003-07-05 Bruno Haible + + * format-perl-brace.c: Renamed from format-perl-bracket.c. Recognize + braces instead of brackets. + * format.h (formatstring_perl_brace): Renamed from + formatstring_perl_bracket. + * format.c (formatstring_parsers): Add formatstring_perl_brace, remove + formatstring_perl_bracket. + * message.h (enum format_type): Add format_perl_brace, remove + format_perl_bracket. + * message.c (format_language, format_language_pretty): Update. + * x-perl.h (SCANNERS_PERL): Update. + * Makefile.am (FORMAT_SOURCE): Add format-perl-brace.c, remove + format-perl-bracket.c. + * Makefile.msvc (OBJECTS): Add format-perl-brace.obj, remove + format-perl-bracket.obj. + (format-perl-brace.obj): Renamed from format-perl-bracket.obj. + * Makefile.vms (OBJECTS): Add format-perl-brace.obj, remove + format-perl-bracket.obj. + (format-perl-brace.obj): Renamed from format-perl-bracket.obj. + 2003-07-03 Bruno Haible Support for PHP >= 4.2.0. diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index 8ef0272eb..305ab8c7a 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -93,7 +93,7 @@ read-properties.c open-po.c dir-list.c str-list.c FORMAT_SOURCE = format.c format-invalid.h \ format-c.c format-python.c format-lisp.c format-elisp.c format-librep.c \ format-java.c format-awk.c format-pascal.c format-ycp.c format-tcl.c \ -format-perl.c format-perl-bracket.c format-php.c +format-perl.c format-perl-brace.c format-php.c # libgettextsrc contains all code that is needed by at least two programs. libgettextsrc_la_SOURCES = \ diff --git a/gettext-tools/src/Makefile.msvc b/gettext-tools/src/Makefile.msvc index 8f5749b9a..3715941b9 100644 --- a/gettext-tools/src/Makefile.msvc +++ b/gettext-tools/src/Makefile.msvc @@ -140,7 +140,7 @@ OBJECTS = \ format-ycp.obj \ format-tcl.obj \ format-perl.obj \ - format-perl-bracket.obj \ + format-perl-brace.obj \ format-php.obj msgcmp_OBJECTS = msgcmp.obj @@ -271,8 +271,8 @@ format-tcl.obj : format-tcl.c format-perl.obj : format-perl.c $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c format-perl.c -format-perl-bracket.obj : format-perl-bracket.c - $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c format-perl-bracket.c +format-perl-brace.obj : format-perl-brace.c + $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c format-perl-brace.c format-php.obj : format-php.c $(CC) $(INCLUDES) $(CFLAGS) $(PICFLAGS) -c format-php.c diff --git a/gettext-tools/src/Makefile.vms b/gettext-tools/src/Makefile.vms index 97a0caad8..8e116faa0 100644 --- a/gettext-tools/src/Makefile.vms +++ b/gettext-tools/src/Makefile.vms @@ -86,7 +86,7 @@ OBJECTS = \ format-ycp.obj, \ format-tcl.obj, \ format-perl.obj, \ - format-perl-bracket.obj, \ + format-perl-brace.obj, \ format-php.obj msgcmp_OBJECTS = msgcmp.obj @@ -215,8 +215,8 @@ format-tcl.obj : format-tcl.c format-perl.obj : format-perl.c $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) format-perl.c -format-perl-bracket.obj : format-perl-bracket.c - $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) format-perl-bracket.c +format-perl-brace.obj : format-perl-brace.c + $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) format-perl-brace.c format-php.obj : format-php.c $(CC) $(INCLUDES) $(CFLAGS) /define=($(DEFS)) format-php.c diff --git a/gettext-tools/src/format-perl-brace.c b/gettext-tools/src/format-perl-brace.c index 688fcfdc6..334e194cf 100644 --- a/gettext-tools/src/format-perl-brace.c +++ b/gettext-tools/src/format-perl-brace.c @@ -1,4 +1,4 @@ -/* Perl bracketed format strings. +/* Perl brace format strings. Copyright (C) 2003 Free Software Foundation, Inc. Written by Bruno Haible , 2003. @@ -32,12 +32,12 @@ #define _(str) gettext (str) -/* Perl bracketed format strings are supported by Guido Flohr's libintl-perl +/* Perl brace format strings are supported by Guido Flohr's libintl-perl package, more precisely by the __expand and __x functions therein. A format string directive here consists of - - an opening bracket '[', + - an opening brace '{', - an identifier [_A-Za-z][_0-9A-Za-z]*, - - a closing bracket ']'. + - a closing brace '}'. */ struct named_arg @@ -79,7 +79,7 @@ format_parse (const char *format, char **invalid_reason) spec.named = NULL; for (; *format != '\0';) - if (*format++ == '[') + if (*format++ == '{') { const char *f = format; char c; @@ -91,7 +91,7 @@ format_parse (const char *format, char **invalid_reason) c = *++f; while ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || (c >= '0' && c <= '9')); - if (c == ']') + if (c == '}') { /* A directive. */ char *name; @@ -183,7 +183,7 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr, /* Check the argument names in spec1 are contained in those of spec2. Additional arguments in spec2 are allowed; they expand to themselves - (including the surrounding brackets) at runtime. + (including the surrounding braces) at runtime. Both arrays are sorted. We search for the differences. */ for (i = 0, j = 0; i < n1 || j < n2; ) { @@ -220,7 +220,7 @@ format_check (const lex_pos_ty *pos, void *msgid_descr, void *msgstr_descr, } -struct formatstring_parser formatstring_perl_bracket = +struct formatstring_parser formatstring_perl_brace = { format_parse, format_free, @@ -294,7 +294,7 @@ main () /* * For Emacs M-x compile * Local Variables: - * compile-command: "/bin/sh ../libtool --mode=link gcc -o a.out -static -O -g -Wall -I.. -I../lib -I../intl -DHAVE_CONFIG_H -DTEST format-perl-bracket.c ../lib/libgettextlib.la" + * compile-command: "/bin/sh ../libtool --mode=link gcc -o a.out -static -O -g -Wall -I.. -I../lib -I../intl -DHAVE_CONFIG_H -DTEST format-perl-brace.c ../lib/libgettextlib.la" * End: */ diff --git a/gettext-tools/src/format.c b/gettext-tools/src/format.c index 0dc216fd5..17423f340 100644 --- a/gettext-tools/src/format.c +++ b/gettext-tools/src/format.c @@ -38,6 +38,6 @@ struct formatstring_parser *formatstring_parsers[NFORMATS] = /* format_ycp */ &formatstring_ycp, /* format_tcl */ &formatstring_tcl, /* format_perl */ &formatstring_perl, - /* format_perl_bracket */ &formatstring_perl_bracket, + /* format_perl_brace */ &formatstring_perl_brace, /* format_php */ &formatstring_php }; diff --git a/gettext-tools/src/format.h b/gettext-tools/src/format.h index ca0d61c1b..6cd241be1 100644 --- a/gettext-tools/src/format.h +++ b/gettext-tools/src/format.h @@ -67,7 +67,7 @@ extern struct formatstring_parser formatstring_pascal; extern struct formatstring_parser formatstring_ycp; extern struct formatstring_parser formatstring_tcl; extern struct formatstring_parser formatstring_perl; -extern struct formatstring_parser formatstring_perl_bracket; +extern struct formatstring_parser formatstring_perl_brace; extern struct formatstring_parser formatstring_php; /* Table of all format string parsers. */ diff --git a/gettext-tools/src/message.c b/gettext-tools/src/message.c index e72957451..294506303 100644 --- a/gettext-tools/src/message.c +++ b/gettext-tools/src/message.c @@ -46,7 +46,7 @@ const char *const format_language[NFORMATS] = /* format_ycp */ "ycp", /* format_tcl */ "tcl", /* format_perl */ "perl", - /* format_perl_bracket */ "perl-bracket", + /* format_perl_brace */ "perl-brace", /* format_php */ "php" }; @@ -64,7 +64,7 @@ const char *const format_language_pretty[NFORMATS] = /* format_ycp */ "YCP", /* format_tcl */ "Tcl", /* format_perl */ "Perl", - /* format_perl_bracket */ "Perl bracket", + /* format_perl_brace */ "Perl brace", /* format_php */ "PHP" }; diff --git a/gettext-tools/src/message.h b/gettext-tools/src/message.h index 2926ca2a7..a64c86ce2 100644 --- a/gettext-tools/src/message.h +++ b/gettext-tools/src/message.h @@ -46,7 +46,7 @@ enum format_type format_ycp, format_tcl, format_perl, - format_perl_bracket, + format_perl_brace, format_php }; #define NFORMATS 14 /* Number of format_type enum values. */ diff --git a/gettext-tools/src/x-perl.h b/gettext-tools/src/x-perl.h index 0f67b0329..9c28df66b 100644 --- a/gettext-tools/src/x-perl.h +++ b/gettext-tools/src/x-perl.h @@ -24,7 +24,7 @@ { "cgi", "perl" }, \ #define SCANNERS_PERL \ - { "perl", extract_perl, &formatstring_perl, &formatstring_perl_bracket }, \ + { "perl", extract_perl, &formatstring_perl, &formatstring_perl_brace }, \ /* Scan a Perl file and add its translatable strings to mdlp. */ extern void extract_perl (FILE *fp, const char *real_filename, diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index cd470fc8c..988d42dd6 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,16 @@ +2003-07-05 Bruno Haible + + * format-perl-brace-1: Renamed from format-perl-bracket-1. Use braces + instead of brackets. + * format-perl-brace-2: Renamed from format-perl-bracket-2. Use braces + instead of brackets. + * format-perl-mixed-1: Use braces instead of brackets. + * format-perl-mixed-2: Likewise. + * xgettext-26: Likewise. + * lang-perl-2: Likewise. + * Makefile.am (TESTS): Add format-perl-brace-[12], remove + format-perl-bracket-[12]. + 2003-06-27 Bruno Haible * xgettext-27: Also test Unicode character names in here documents. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index fa18e38a8..ad29fc329 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -61,7 +61,7 @@ TESTS = gettext-1 gettext-2 \ format-python-1 format-python-2 \ format-pascal-1 format-pascal-2 \ format-perl-1 format-perl-2 \ - format-perl-bracket-1 format-perl-bracket-2 \ + format-perl-brace-1 format-perl-brace-2 \ format-perl-mixed-1 format-perl-mixed-2 \ format-tcl-1 format-tcl-2 \ format-ycp-1 format-ycp-2 \ diff --git a/gettext-tools/tests/format-perl-brace-1 b/gettext-tools/tests/format-perl-brace-1 index 16ce6842f..e05aba585 100755 --- a/gettext-tools/tests/format-perl-brace-1 +++ b/gettext-tools/tests/format-perl-brace-1 @@ -1,6 +1,6 @@ #! /bin/sh -# Test recognition of Perl bracket format strings. +# Test recognition of Perl brace format strings. tmpfiles="" trap 'rm -fr $tmpfiles' 1 2 3 15 @@ -10,25 +10,25 @@ cat <<\EOF > f-pb-1.data # Invalid: no argument "abc" # Valid: a named argument -"abc[value]" +"abc{value}" # Invalid: an empty name -"abc[]" +"abc{}" # Invalid: unterminated name -"abc[value" +"abc{value" # Valid: three arguments, two with equal names -"abc[addr],[char],[addr]" +"abc{addr},{char},{addr}" # Invalid: place-holder contains a space. -"[foo bar]" +"{foo bar}" # Invalid: missing right angle bracket. -"[foo bar" +"{foo bar" # Valid: not nested, but one single place-holder. -"[foo[bar]baz]" +"{foo{bar}baz}" # Valid: no nesting error, but one single place-holder. -"[foo[bar]baz" +"{foo{bar}baz" # Valid: place-holder with spaces must be ignored, but still one remaining. -"[foo bar] [baz]" +"{foo bar} {baz}" # Invalid: percent sign not allowed. -"[foo%bar]" +"{foo%bar}" EOF : ${XGETTEXT=xgettext} @@ -50,7 +50,7 @@ EOF fail=yes fi else - if grep perl-bracket-format f-pb-1-$n.po > /dev/null; then + if grep perl-brace-format f-pb-1-$n.po > /dev/null; then fail=yes else : diff --git a/gettext-tools/tests/format-perl-brace-2 b/gettext-tools/tests/format-perl-brace-2 index bd750c330..c00636bfa 100755 --- a/gettext-tools/tests/format-perl-brace-2 +++ b/gettext-tools/tests/format-perl-brace-2 @@ -1,6 +1,6 @@ #! /bin/sh -# Test checking of Perl bracket format strings. +# Test checking of Perl brace format strings. tmpfiles="" trap 'rm -fr $tmpfiles' 1 2 3 15 @@ -8,26 +8,26 @@ trap 'rm -fr $tmpfiles' 1 2 3 15 tmpfiles="$tmpfiles f-pb-2.data" cat <<\EOF > f-pb-2.data # Valid: same named arguments -msgid "abc[date][time]" -msgstr "xyz[date][time]" +msgid "abc{date}{time}" +msgstr "xyz{date}{time}" # Valid: permutation -msgid "abc[x3][x1][x2]def" -msgstr "xyz[x2][x1][x3]" +msgid "abc{x3}{x1}{x2}def" +msgstr "xyz{x2}{x1}{x3}" # Invalid: missing argument -msgid "abc[x2]def[x1]" -msgstr "xyz[x1]" +msgid "abc{x2}def{x1}" +msgstr "xyz{x1}" # Invalid: missing argument -msgid "abc[x1]def[x2]" -msgstr "xyz[x2]" -# Valid: added argument (valid since "[zoo]" expands to itself) -msgid "abc[foo]def" -msgstr "xyz[foo]uvw[zoo]" +msgid "abc{x1}def{x2}" +msgstr "xyz{x2}" +# Valid: added argument (valid since "{zoo}" expands to itself) +msgid "abc{foo}def" +msgstr "xyz{foo}uvw{zoo}" # Valid: multiple reuse of same argument -msgid "[foo] [bar] [baz]" -msgstr "[baz] [bar] [foo] [bar]" +msgid "{foo} {bar} {baz}" +msgstr "{baz} {bar} {foo} {bar}" # Valid: single reuse of same argument -msgid "[baz] [bar] [foo] [bar]" -msgstr "[foo] [bar] [baz]" +msgid "{baz} {bar} {foo} {bar}" +msgstr "{foo} {bar} {baz}" EOF : ${MSGFMT=msgfmt} @@ -38,7 +38,7 @@ while read comment; do n=`expr $n + 1` tmpfiles="$tmpfiles f-pb-2-$n.po f-pb-2-$n.mo" cat < f-pb-2-$n.po -#, perl-bracket-format +#, perl-brace-format ${msgid_line} ${msgstr_line} EOF diff --git a/gettext-tools/tests/format-perl-mixed-1 b/gettext-tools/tests/format-perl-mixed-1 index 83da4a6f6..3b3a84b89 100755 --- a/gettext-tools/tests/format-perl-mixed-1 +++ b/gettext-tools/tests/format-perl-mixed-1 @@ -1,6 +1,6 @@ #! /bin/sh -# Test recognition of Perl format strings of both kinds (printf and bracketed). +# Test recognition of Perl format strings of both kinds (printf and brace). # This test is for the combination of both kinds. tmpfiles="" @@ -10,23 +10,23 @@ tmpfiles="$tmpfiles f-pm-1.data" cat <<\EOF > f-pm-1.data # Both formats. -#, perl-format, perl-bracket-format -"[foo] %c [bar] %d [baz]" +#, perl-format, perl-brace-format +"{foo} %c {bar} %d {baz}" # printf format only. #, perl-format "%c %d" # printf format only, because '%' is not allowed in identifier. #, perl-format -"[foo%cbar]" +"{foo%cbar}" # Valid bracketed format because there is still one valid identifier. -#, perl-format, perl-bracket-format -"[foo%cbar] [baz]" +#, perl-format, perl-brace-format +"{foo%cbar} {baz}" # Bracketed format only, because %l is not recognized in printf format. -#, perl-bracket-format -"[foo] %l [bar]" +#, perl-brace-format +"{foo} %l {bar}" # Neither format recognized here. -"[foo bar %l" +"{foo bar %l" EOF : ${XGETTEXT=xgettext} diff --git a/gettext-tools/tests/format-perl-mixed-2 b/gettext-tools/tests/format-perl-mixed-2 index 696315cd9..09afbbb5b 100755 --- a/gettext-tools/tests/format-perl-mixed-2 +++ b/gettext-tools/tests/format-perl-mixed-2 @@ -1,7 +1,7 @@ #! /bin/sh # Test checking of Perl format strings. -# This test is for the combination of printf and bracketed format strings. +# This test is for the combination of printf and brace format strings. tmpfiles="" trap 'rm -fr $tmpfiles' 1 2 3 15 @@ -9,32 +9,32 @@ trap 'rm -fr $tmpfiles' 1 2 3 15 tmpfiles="$tmpfiles f-pm-2.data" cat <<\EOF > f-pm-2.data # Valid: normal case. -#, perl-format, perl-bracket-format -msgid "[foo] %d [bar] %s" -msgstr "[bar] [foo] %d %s" +#, perl-format, perl-brace-format +msgid "{foo} %d {bar} %s" +msgstr "{bar} {foo} %d %s" # Invalid: missing argument. -#, perl-format, perl-bracket-format -msgid "[foo] %d [bar] %s" -msgstr "[bar] %d %s" +#, perl-format, perl-brace-format +msgid "{foo} %d {bar} %s" +msgstr "{bar} %d %s" # Valid: missing argument but checking disabled. -#, perl-format, no-perl-bracket-format -msgid "[foo] %d [bar] %s" -msgstr "[bar] %d %s" +#, perl-format, no-perl-brace-format +msgid "{foo} %d {bar} %s" +msgstr "{bar} %d %s" # Invalid: printf format reordered without position specifiers %1$, %2$. -#, perl-format, perl-bracket-format -msgid "[foo] %d [bar] %s" -msgstr "[bar] %s [foo] %d" +#, perl-format, perl-brace-format +msgid "{foo} %d {bar} %s" +msgstr "{bar} %s {foo} %d" # Valid: same thing but checking disabled. -#, no-perl-format, perl-bracket-format -msgid "[foo] %d [bar] %s" -msgstr "[bar] %s [foo] %d" +#, no-perl-format, perl-brace-format +msgid "{foo} %d {bar} %s" +msgstr "{bar} %s {foo} %d" # Invalid: unnamed vs. named arguments #, perl-format msgid "abc%sdef" -msgstr "xyz[value]" +msgstr "xyz{value}" # Invalid: named vs. unnamed arguments -#, perl-bracket-format -msgid "abc[value]def" +#, perl-brace-format +msgid "abc{value}def" msgstr "xyz%s" EOF diff --git a/gettext-tools/tests/lang-perl-2 b/gettext-tools/tests/lang-perl-2 index 7b7ebccda..6948ac12d 100755 --- a/gettext-tools/tests/lang-perl-2 +++ b/gettext-tools/tests/lang-perl-2 @@ -1,7 +1,7 @@ #! /bin/sh # Test of gettext facilities in the Perl language, -# using bracket format strings. +# using brace format strings. # Assumes an fr_FR locale is installed. # Assumes the following packages are installed: perl, libintl-perl. @@ -16,7 +16,7 @@ print __"'Your command, please?', asked the waiter."; print "\n" printf __n ("a piece of cake", "%d pieces of cake", $n), $n; print "\n" -printf __x ("[old] is replaced by [new].", old => "FF", new => "EUR"); +printf __x ("{old} is replaced by {new}.", old => "FF", new => "EUR"); print "\n" EOF @@ -35,8 +35,8 @@ msgid_plural "%d pieces of cake" msgstr[0] "" msgstr[1] "" -#, perl-bracket-format -msgid "[old] is replaced by [new]." +#, perl-brace-format +msgid "{old} is replaced by {new}." msgstr "" EOF @@ -61,9 +61,9 @@ msgstr[0] "un morceau de gateau" msgstr[1] "%d morceaux de gateau" # Reverse the arguments. -#, perl-bracket-format -msgid "[old] is replaced by [new]." -msgstr "[new] remplace [old]." +#, perl-brace-format +msgid "{old} is replaced by {new}." +msgstr "{new} remplace {old}." EOF tmpfiles="$tmpfiles fr.po.new" diff --git a/gettext-tools/tests/xgettext-26 b/gettext-tools/tests/xgettext-26 index 9f2f55ce5..21c2eebc0 100755 --- a/gettext-tools/tests/xgettext-26 +++ b/gettext-tools/tests/xgettext-26 @@ -108,23 +108,23 @@ printf "%s\n", gettext qq(mari\\\\huana); printf "%s\n", gettext qq(mari\\\\\huana); # Recognition of format strings. -gettext "This is [only] a bracketed formatstring."; -gettext "This is %s [mixed]."; +gettext "This is {only} a brace formatstring."; +gettext "This is %s {mixed}."; gettext "This is only %c."; gettext "This is nothing at all."; gettext "And this is %l also no format at all."; -# xgettext: no-perl-format, perl-bracket-format -gettext "The function '[func]' expects '%c' here."; +# xgettext: no-perl-format, perl-brace-format +gettext "The function '{func}' expects '%c' here."; # This is a contradictory case: The same string three times, # with different xgettext comments. -# xgettext: perl-bracket-format, no-perl-format -gettext "Left as an %exercise to [maintainer]."; -# xgettext: no-perl-bracket-format, perl-format -gettext "Left as an %exercise to [maintainer]."; +# xgettext: perl-brace-format, no-perl-format +gettext "Left as an %exercise to {maintainer}."; +# xgettext: no-perl-brace-format, perl-format +gettext "Left as an %exercise to {maintainer}."; # No xgettext comment this time. -gettext "Left as an %exercise to [maintainer]."; +gettext "Left as an %exercise to {maintainer}."; __END__ gettext "Discarded!"; EOF @@ -262,13 +262,13 @@ msgid "mari\\\\huana" msgstr "" #: xg-test26.pl:102 -#, perl-bracket-format -msgid "This is [only] a bracketed formatstring." +#, perl-brace-format +msgid "This is {only} a brace formatstring." msgstr "" #: xg-test26.pl:103 -#, perl-format, perl-bracket-format -msgid "This is %s [mixed]." +#, perl-format, perl-brace-format +msgid "This is %s {mixed}." msgstr "" #: xg-test26.pl:104 @@ -285,13 +285,13 @@ msgid "And this is %l also no format at all." msgstr "" #: xg-test26.pl:109 -#, no-perl-format, perl-bracket-format -msgid "The function '[func]' expects '%c' here." +#, no-perl-format, perl-brace-format +msgid "The function '{func}' expects '%c' here." msgstr "" #: xg-test26.pl:114 xg-test26.pl:116 xg-test26.pl:118 -#, perl-format, no-perl-bracket-format -msgid "Left as an %exercise to [maintainer]." +#, perl-format, no-perl-brace-format +msgid "Left as an %exercise to {maintainer}." msgstr "" EOF