Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Locale-Maketext-Lexicon CPAN distribution.

Report information
The Basics
Id: 39057
Status: resolved
Priority: 0/
Queue: Locale-Maketext-Lexicon

People
Owner: Nobody in particular
Requestors: felix.ostmann [...] thewar.de
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: concat in loc() works now and TT can now use [% FILTER loc %]
now it is possible to concat strings in loc() and in TT you can use [% FILTER loc %]
Subject: tests-for-new-patch-for-concat-and-tt-FILTER.patch
--- Locale-Maketext-Lexicon-0.68/t/5-extract.t.orig 2008-09-07 02:13:04.000000000 +0200 +++ Locale-Maketext-Lexicon-0.68/t/5-extract.t 2008-09-07 03:23:01.000000000 +0200 @@ -1,7 +1,7 @@ #! /usr/bin/perl -w use lib '../lib'; use strict; -use Test::More tests => 43; +use Test::More tests => 47; use_ok('Locale::Maketext::Extract'); my $Ext = Locale::Maketext::Extract->new; @@ -61,6 +61,12 @@ extract_ok(q(_("","car")) => '', 'ignore empty string'); extract_ok(q(_("0")) => '', 'ignore zero'); +extract_ok(<<'__EXAMPLE__' => 'foo bar baz', 'use FILTER (tt)'); +[% FILTER l -%] +foo bar baz +[%- END %] +__EXAMPLE__ + extract_ok(<<'__EXAMPLE__' => 'foo bar baz', 'trim the string (tt)'); [% |loc -%] foo bar baz @@ -173,6 +179,50 @@ msgstr "" __EXPECTED__ +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "concat (heredoc)"); +_('exam'.<<"", 10) +ple1 %1 + +__EXAMPLE__ +#: :1 +#. (10) +msgid "example1 %1\n" +msgstr "" +__EXPECTED__ + +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "two _() calls with concat over multiline (heredoc)"); +_('example' . +<<"", 10) +1 %1 + +_(<<"", 5) +example2 %1 + +__EXAMPLE__ +#: :1 +#. (10) +msgid "example1 %1\n" +msgstr "" + +#: :5 +#. (5) +msgid "example2 %1\n" +msgstr "" +__EXPECTED__ + +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "i can concat the world!"); +_( +'\$foo' +."\$bar" +.<<'' +\$baz + +) +__EXAMPLE__ +#: :2 +msgid "\\$foo$bar\\$baz\n" +msgstr "" +__EXPECTED__ sub extract_ok { my ($text, $expected, $info, $verbatim) = @_;
Subject: patch-for-concat-and-tt-FILTER.patch
--- Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm.orig 2008-09-07 02:12:33.000000000 +0200 +++ Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm 2008-09-07 03:22:12.000000000 +0200 @@ -255,7 +255,7 @@ # Template Toolkit $line = 1; pos($_) = 0; - while (m!\G(.*?\[%-?\s*\|l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { + while (m!\G(.*?\[%-?\s*(?:\|\s*|FILTER\s+)l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { my ($vars, $trim_start, $str, $trim_end) = ($2, $3, $4, $5); $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! $vars =~ s/^\s*\(//; @@ -305,7 +305,7 @@ } # Perl code: - my ($state,$str,$vars,$quo,$heredoc)=(0); + my ($state,$line_offset,$str,$str_part,$vars,$quo,$heredoc)=(0,0); pos($_) = 0; my $orig = 1 + (() = ((my $__ = $_) =~ /\n/g)); @@ -322,28 +322,45 @@ $state == BEG && m/^([\S\(])\s*/gc && do { $state = ( ($1 eq '(') ? PAR : NUL); redo }; + # concat + $state == PAR && defined($str) && m/^(\s*\.\s*)/gc + && do { $line_offset += (() = ((my $__ = $1) =~ /\n/g)); redo }; + + # str_part + $state == PAR && defined($str_part) && do { + if (($quo == QUO1) || ($quo == QUO5) ){ + $str_part =~ s/\\([\\'])/$1/g if ($str_part); # normalize q strings + } + elsif ($quo != QUO6) { + $str_part =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str_part); # normalize qq / qx strings + } + $str .= $str_part; + undef $str_part; undef $quo; + redo; + }; + # begin or end of string $state == PAR && m/^(\')/gc && do { $state = $quo = QUO1; redo }; - $state == QUO1 && m/^([^'\\]+)/gc && do { $str .= $1; redo }; - $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; + $state == QUO1 && m/^([^'\\]+)/gc && do { $str_part .= $1; redo }; + $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; $state == QUO1 && m/^\'/gc && do { $state = PAR; redo }; $state == PAR && m/^\"/gc && do { $state = $quo = QUO2; redo }; - $state == QUO2 && m/^([^"\\]+)/gc && do { $str .= $1; redo }; - $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; + $state == QUO2 && m/^([^"\\]+)/gc && do { $str_part .= $1; redo }; + $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; $state == QUO2 && m/^\"/gc && do { $state = PAR; redo }; $state == PAR && m/^\`/gc && do { $state = $quo = QUO3; redo }; - $state == QUO3 && m/^([^\`]*)/gc && do { $str .= $1; redo }; + $state == QUO3 && m/^([^\`]*)/gc && do { $str_part .= $1; redo }; $state == QUO3 && m/^\`/gc && do { $state = PAR; redo }; $state == PAR && m/^qq\{/gc && do { $state = $quo = QUO4; redo }; - $state == QUO4 && m/^([^\}]*)/gc && do { $str .= $1; redo }; + $state == QUO4 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; $state == QUO4 && m/^\}/gc && do { $state = PAR; redo }; $state == PAR && m/^q\{/gc && do { $state = $quo = QUO5; redo }; - $state == QUO5 && m/^([^\}]*)/gc && do { $str .= $1; redo }; + $state == QUO5 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; $state == QUO5 && m/^\}/gc && do { $state = PAR; redo }; # find heredoc terminator, then get the heredoc and go back to current position @@ -360,7 +377,7 @@ $state == PAR && m/^<<(\w*)/gc && do { $state = HERE; $quo = QUO7; $heredoc = $1; redo }; # jump ahaid and get the heredoc, then s/// also reset the pos and we are back at the current pos - $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str .= $1; redo }; + $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str_part .= $1; $line_offset++; redo }; # end () # @@ -368,15 +385,9 @@ $state == PAR && m/^\s*[\)]/gc && do { $state = NUL; $vars =~ s/[\n\r]//g if ($vars); - if (($quo == QUO1) || ($quo == QUO5) ){ - $str =~ s/\\([\\'])/$1/g if ($str); # normalize q strings - } - elsif ($quo != QUO6) { - $str =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str); # normalize qq / qx strings - } - # heredoc loosing the terminating line, so decrement one more line for heredoc - push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - defined($heredoc), $vars] if ($str); + push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - $line_offset, $vars] if ($str); undef $str; undef $vars; undef $heredoc; + $line_offset = 0; redo; };
Subject: Re: [rt.cpan.org #39057] concat in loc() works now and TT can now use [% FILTER loc %]
Date: Sun, 7 Sep 2008 15:00:59 -0400
To: Felix Antonius Wilhelm Ostmann via RT <bug-Locale-Maketext-Lexicon [...] rt.cpan.org>
From: jesse <jesse [...] fsck.com>
Is it worth adding something to the documentation to make it more obvious to end users? -j On Sat, Sep 06, 2008 at 09:40:58PM -0400, Felix Antonius Wilhelm Ostmann via RT wrote: Show quoted text
> Sat Sep 06 21:40:27 2008: Request 39057 was acted upon. > Transaction: Ticket created by Sadrak > Queue: Locale-Maketext-Lexicon > Subject: concat in loc() works now and TT can now use [% FILTER loc %] > Broken in: (no value) > Severity: Wishlist > Owner: Nobody > Requestors: felix.ostmann@thewar.de > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > > > > now it is possible to concat strings in loc() and in TT you can use [% > FILTER loc %]
Show quoted text
> --- Locale-Maketext-Lexicon-0.68/t/5-extract.t.orig 2008-09-07 02:13:04.000000000 +0200 > +++ Locale-Maketext-Lexicon-0.68/t/5-extract.t 2008-09-07 03:23:01.000000000 +0200 > @@ -1,7 +1,7 @@ > #! /usr/bin/perl -w > use lib '../lib'; > use strict; > -use Test::More tests => 43; > +use Test::More tests => 47; > > use_ok('Locale::Maketext::Extract'); > my $Ext = Locale::Maketext::Extract->new; > @@ -61,6 +61,12 @@ > extract_ok(q(_("","car")) => '', 'ignore empty string'); > extract_ok(q(_("0")) => '', 'ignore zero'); > > +extract_ok(<<'__EXAMPLE__' => 'foo bar baz', 'use FILTER (tt)'); > +[% FILTER l -%] > +foo bar baz > +[%- END %] > +__EXAMPLE__ > + > extract_ok(<<'__EXAMPLE__' => 'foo bar baz', 'trim the string (tt)'); > [% |loc -%] > foo bar baz > @@ -173,6 +179,50 @@ > msgstr "" > __EXPECTED__ > > +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "concat (heredoc)"); > +_('exam'.<<"", 10) > +ple1 %1 > + > +__EXAMPLE__ > +#: :1 > +#. (10) > +msgid "example1 %1\n" > +msgstr "" > +__EXPECTED__ > + > +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "two _() calls with concat over multiline (heredoc)"); > +_('example' . > +<<"", 10) > +1 %1 > + > +_(<<"", 5) > +example2 %1 > + > +__EXAMPLE__ > +#: :1 > +#. (10) > +msgid "example1 %1\n" > +msgstr "" > + > +#: :5 > +#. (5) > +msgid "example2 %1\n" > +msgstr "" > +__EXPECTED__ > + > +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "i can concat the world!"); > +_( > +'\$foo' > +."\$bar" > +.<<'' > +\$baz > + > +) > +__EXAMPLE__ > +#: :2 > +msgid "\\$foo$bar\\$baz\n" > +msgstr "" > +__EXPECTED__ > > sub extract_ok { > my ($text, $expected, $info, $verbatim) = @_;
Show quoted text
> --- Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm.orig 2008-09-07 02:12:33.000000000 +0200 > +++ Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm 2008-09-07 03:22:12.000000000 +0200 > @@ -255,7 +255,7 @@ > > # Template Toolkit > $line = 1; pos($_) = 0; > - while (m!\G(.*?\[%-?\s*\|l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { > + while (m!\G(.*?\[%-?\s*(?:\|\s*|FILTER\s+)l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { > my ($vars, $trim_start, $str, $trim_end) = ($2, $3, $4, $5); > $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! > $vars =~ s/^\s*\(//; > @@ -305,7 +305,7 @@ > } > > # Perl code: > - my ($state,$str,$vars,$quo,$heredoc)=(0); > + my ($state,$line_offset,$str,$str_part,$vars,$quo,$heredoc)=(0,0); > pos($_) = 0; > my $orig = 1 + (() = ((my $__ = $_) =~ /\n/g)); > > @@ -322,28 +322,45 @@ > $state == BEG && m/^([\S\(])\s*/gc > && do { $state = ( ($1 eq '(') ? PAR : NUL); redo }; > > + # concat > + $state == PAR && defined($str) && m/^(\s*\.\s*)/gc > + && do { $line_offset += (() = ((my $__ = $1) =~ /\n/g)); redo }; > + > + # str_part > + $state == PAR && defined($str_part) && do { > + if (($quo == QUO1) || ($quo == QUO5) ){ > + $str_part =~ s/\\([\\'])/$1/g if ($str_part); # normalize q strings > + } > + elsif ($quo != QUO6) { > + $str_part =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str_part); # normalize qq / qx strings > + } > + $str .= $str_part; > + undef $str_part; undef $quo; > + redo; > + }; > + > # begin or end of string > $state == PAR && m/^(\')/gc && do { $state = $quo = QUO1; redo }; > - $state == QUO1 && m/^([^'\\]+)/gc && do { $str .= $1; redo }; > - $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; > + $state == QUO1 && m/^([^'\\]+)/gc && do { $str_part .= $1; redo }; > + $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; > $state == QUO1 && m/^\'/gc && do { $state = PAR; redo }; > > $state == PAR && m/^\"/gc && do { $state = $quo = QUO2; redo }; > - $state == QUO2 && m/^([^"\\]+)/gc && do { $str .= $1; redo }; > - $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; > + $state == QUO2 && m/^([^"\\]+)/gc && do { $str_part .= $1; redo }; > + $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; > $state == QUO2 && m/^\"/gc && do { $state = PAR; redo }; > > $state == PAR && m/^\`/gc && do { $state = $quo = QUO3; redo }; > - $state == QUO3 && m/^([^\`]*)/gc && do { $str .= $1; redo }; > + $state == QUO3 && m/^([^\`]*)/gc && do { $str_part .= $1; redo }; > $state == QUO3 && m/^\`/gc && do { $state = PAR; redo }; > > $state == PAR && m/^qq\{/gc && do { $state = $quo = QUO4; redo }; > - $state == QUO4 && m/^([^\}]*)/gc && do { $str .= $1; redo }; > + $state == QUO4 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; > $state == QUO4 && m/^\}/gc && do { $state = PAR; redo }; > > > $state == PAR && m/^q\{/gc && do { $state = $quo = QUO5; redo }; > - $state == QUO5 && m/^([^\}]*)/gc && do { $str .= $1; redo }; > + $state == QUO5 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; > $state == QUO5 && m/^\}/gc && do { $state = PAR; redo }; > > # find heredoc terminator, then get the heredoc and go back to current position > @@ -360,7 +377,7 @@ > $state == PAR && m/^<<(\w*)/gc && do { $state = HERE; $quo = QUO7; $heredoc = $1; redo }; > > # jump ahaid and get the heredoc, then s/// also reset the pos and we are back at the current pos > - $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str .= $1; redo }; > + $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str_part .= $1; $line_offset++; redo }; > > # end () > # > @@ -368,15 +385,9 @@ > $state == PAR && m/^\s*[\)]/gc && do { > $state = NUL; > $vars =~ s/[\n\r]//g if ($vars); > - if (($quo == QUO1) || ($quo == QUO5) ){ > - $str =~ s/\\([\\'])/$1/g if ($str); # normalize q strings > - } > - elsif ($quo != QUO6) { > - $str =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str); # normalize qq / qx strings > - } > - # heredoc loosing the terminating line, so decrement one more line for heredoc > - push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - defined($heredoc), $vars] if ($str); > + push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - $line_offset, $vars] if ($str); > undef $str; undef $vars; undef $heredoc; > + $line_offset = 0; > redo; > }; >
--
Subject: Re: [rt.cpan.org #39057] concat in loc() works now and TT can now use [% FILTER loc %]
Date: Sun, 07 Sep 2008 21:18:05 +0200
To: bug-Locale-Maketext-Lexicon [...] rt.cpan.org
From: Felix Antonius Wilhelm Ostmann <felix.ostmann [...] thewar.de>
uh, it was so late :) at which point in the docu? i cant find a position where i can incluse such information about that feature :-/ Jesse via RT schrieb: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > > > Is it worth adding something to the documentation to make it more > obvious to end users? > > -j > > > On Sat, Sep 06, 2008 at 09:40:58PM -0400, Felix Antonius Wilhelm Ostmann via RT wrote:
>> Sat Sep 06 21:40:27 2008: Request 39057 was acted upon. >> Transaction: Ticket created by Sadrak >> Queue: Locale-Maketext-Lexicon >> Subject: concat in loc() works now and TT can now use [% FILTER loc %] >> Broken in: (no value) >> Severity: Wishlist >> Owner: Nobody >> Requestors: felix.ostmann@thewar.de >> Status: new >> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > >> >> >> now it is possible to concat strings in loc() and in TT you can use [% >> FILTER loc %]
>
>> --- Locale-Maketext-Lexicon-0.68/t/5-extract.t.orig 2008-09-07 02:13:04.000000000 +0200 >> +++ Locale-Maketext-Lexicon-0.68/t/5-extract.t 2008-09-07 03:23:01.000000000 +0200 >> @@ -1,7 +1,7 @@ >> #! /usr/bin/perl -w >> use lib '../lib'; >> use strict; >> -use Test::More tests => 43; >> +use Test::More tests => 47; >> >> use_ok('Locale::Maketext::Extract'); >> my $Ext = Locale::Maketext::Extract->new; >> @@ -61,6 +61,12 @@ >> extract_ok(q(_("","car")) => '', 'ignore empty string'); >> extract_ok(q(_("0")) => '', 'ignore zero'); >> >> +extract_ok(<<'__EXAMPLE__' => 'foo bar baz', 'use FILTER (tt)'); >> +[% FILTER l -%] >> +foo bar baz >> +[%- END %] >> +__EXAMPLE__ >> + >> extract_ok(<<'__EXAMPLE__' => 'foo bar baz', 'trim the string (tt)'); >> [% |loc -%] >> foo bar baz >> @@ -173,6 +179,50 @@ >> msgstr "" >> __EXPECTED__ >> >> +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "concat (heredoc)"); >> +_('exam'.<<"", 10) >> +ple1 %1 >> + >> +__EXAMPLE__ >> +#: :1 >> +#. (10) >> +msgid "example1 %1\n" >> +msgstr "" >> +__EXPECTED__ >> + >> +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "two _() calls with concat over multiline (heredoc)"); >> +_('example' . >> +<<"", 10) >> +1 %1 >> + >> +_(<<"", 5) >> +example2 %1 >> + >> +__EXAMPLE__ >> +#: :1 >> +#. (10) >> +msgid "example1 %1\n" >> +msgstr "" >> + >> +#: :5 >> +#. (5) >> +msgid "example2 %1\n" >> +msgstr "" >> +__EXPECTED__ >> + >> +write_po_ok(<<'__EXAMPLE__' => <<'__EXPECTED__', "i can concat the world!"); >> +_( >> +'\$foo' >> +."\$bar" >> +.<<'' >> +\$baz >> + >> +) >> +__EXAMPLE__ >> +#: :2 >> +msgid "\\$foo$bar\\$baz\n" >> +msgstr "" >> +__EXPECTED__ >> >> sub extract_ok { >> my ($text, $expected, $info, $verbatim) = @_;
>
>> --- Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm.orig 2008-09-07 02:12:33.000000000 +0200 >> +++ Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm 2008-09-07 03:22:12.000000000 +0200 >> @@ -255,7 +255,7 @@ >> >> # Template Toolkit >> $line = 1; pos($_) = 0; >> - while (m!\G(.*?\[%-?\s*\|l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { >> + while (m!\G(.*?\[%-?\s*(?:\|\s*|FILTER\s+)l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { >> my ($vars, $trim_start, $str, $trim_end) = ($2, $3, $4, $5); >> $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! >> $vars =~ s/^\s*\(//; >> @@ -305,7 +305,7 @@ >> } >> >> # Perl code: >> - my ($state,$str,$vars,$quo,$heredoc)=(0); >> + my ($state,$line_offset,$str,$str_part,$vars,$quo,$heredoc)=(0,0); >> pos($_) = 0; >> my $orig = 1 + (() = ((my $__ = $_) =~ /\n/g)); >> >> @@ -322,28 +322,45 @@ >> $state == BEG && m/^([\S\(])\s*/gc >> && do { $state = ( ($1 eq '(') ? PAR : NUL); redo }; >> >> + # concat >> + $state == PAR && defined($str) && m/^(\s*\.\s*)/gc >> + && do { $line_offset += (() = ((my $__ = $1) =~ /\n/g)); redo }; >> + >> + # str_part >> + $state == PAR && defined($str_part) && do { >> + if (($quo == QUO1) || ($quo == QUO5) ){ >> + $str_part =~ s/\\([\\'])/$1/g if ($str_part); # normalize q strings >> + } >> + elsif ($quo != QUO6) { >> + $str_part =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str_part); # normalize qq / qx strings >> + } >> + $str .= $str_part; >> + undef $str_part; undef $quo; >> + redo; >> + }; >> + >> # begin or end of string >> $state == PAR && m/^(\')/gc && do { $state = $quo = QUO1; redo }; >> - $state == QUO1 && m/^([^'\\]+)/gc && do { $str .= $1; redo }; >> - $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; >> + $state == QUO1 && m/^([^'\\]+)/gc && do { $str_part .= $1; redo }; >> + $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; >> $state == QUO1 && m/^\'/gc && do { $state = PAR; redo }; >> >> $state == PAR && m/^\"/gc && do { $state = $quo = QUO2; redo }; >> - $state == QUO2 && m/^([^"\\]+)/gc && do { $str .= $1; redo }; >> - $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; >> + $state == QUO2 && m/^([^"\\]+)/gc && do { $str_part .= $1; redo }; >> + $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; >> $state == QUO2 && m/^\"/gc && do { $state = PAR; redo }; >> >> $state == PAR && m/^\`/gc && do { $state = $quo = QUO3; redo }; >> - $state == QUO3 && m/^([^\`]*)/gc && do { $str .= $1; redo }; >> + $state == QUO3 && m/^([^\`]*)/gc && do { $str_part .= $1; redo }; >> $state == QUO3 && m/^\`/gc && do { $state = PAR; redo }; >> >> $state == PAR && m/^qq\{/gc && do { $state = $quo = QUO4; redo }; >> - $state == QUO4 && m/^([^\}]*)/gc && do { $str .= $1; redo }; >> + $state == QUO4 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; >> $state == QUO4 && m/^\}/gc && do { $state = PAR; redo }; >> >> >> $state == PAR && m/^q\{/gc && do { $state = $quo = QUO5; redo }; >> - $state == QUO5 && m/^([^\}]*)/gc && do { $str .= $1; redo }; >> + $state == QUO5 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; >> $state == QUO5 && m/^\}/gc && do { $state = PAR; redo }; >> >> # find heredoc terminator, then get the heredoc and go back to current position >> @@ -360,7 +377,7 @@ >> $state == PAR && m/^<<(\w*)/gc && do { $state = HERE; $quo = QUO7; $heredoc = $1; redo }; >> >> # jump ahaid and get the heredoc, then s/// also reset the pos and we are back at the current pos >> - $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str .= $1; redo }; >> + $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str_part .= $1; $line_offset++; redo }; >> >> # end () >> # >> @@ -368,15 +385,9 @@ >> $state == PAR && m/^\s*[\)]/gc && do { >> $state = NUL; >> $vars =~ s/[\n\r]//g if ($vars); >> - if (($quo == QUO1) || ($quo == QUO5) ){ >> - $str =~ s/\\([\\'])/$1/g if ($str); # normalize q strings >> - } >> - elsif ($quo != QUO6) { >> - $str =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str); # normalize qq / qx strings >> - } >> - # heredoc loosing the terminating line, so decrement one more line for heredoc >> - push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - defined($heredoc), $vars] if ($str); >> + push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - $line_offset, $vars] if ($str); >> undef $str; undef $vars; undef $heredoc; >> + $line_offset = 0; >> redo; >> }; >>
> >
Subject: Re: [rt.cpan.org #39057] concat in loc() works now and TT can now use [% FILTER loc %]
Date: Sun, 7 Sep 2008 15:24:12 -0400
To: bug-Locale-Maketext-Lexicon [...] rt.cpan.org
From: Jesse Vincent <jesse [...] fsck.com>
On Sep 7, 2008, at 3:18 PM, Felix Antonius Wilhelm Ostmann via RT wrote: Show quoted text
> Queue: Locale-Maketext-Lexicon > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > > > uh, it was so late :) > > at which point in the docu? i cant find a position where i can incluse > such information about that feature :-/
Hmm. I think just adding more examples to Locale::Maketext::Extract's docs is the right thing. It's totally ok for you to only add samples for TT and force a mason guy to do the mason ones ;)
Subject: Re: [rt.cpan.org #39057] concat in loc() works now and TT can now use [% FILTER loc %]
Date: Sun, 07 Sep 2008 22:00:02 +0200
To: bug-Locale-Maketext-Lexicon [...] rt.cpan.org
From: Felix Antonius Wilhelm Ostmann <felix.ostmann [...] thewar.de>
Here is another patch for Locale::Maketext::Extract with a liddle bit more pod ... i dont often write pod, dont know how markup right ... and hope RT handle the attachment :) Jesse via RT schrieb: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > > > > On Sep 7, 2008, at 3:18 PM, Felix Antonius Wilhelm Ostmann via RT wrote: >
>> Queue: Locale-Maketext-Lexicon >> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > >> >> uh, it was so late :) >> >> at which point in the docu? i cant find a position where i can incluse >> such information about that feature :-/
> > > Hmm. > > I think just adding more examples to Locale::Maketext::Extract's docs > is the right thing. > It's totally ok for you to only add samples for TT and force a mason > guy to do the mason ones ;) > >
--- Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm.orig 2008-09-07 02:12:33.000000000 +0200 +++ Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm 2008-09-07 21:57:56.000000000 +0200 @@ -37,6 +37,13 @@ Valid localization function names are: C<translate>, C<maketext>, C<gettext>, C<loc>, C<x>, C<_> and C<__>. +Concatination of all kind of strings are possible, so you can write this: + +_("here my $voice" . "\n" . 'dont fear my [_1]' . <<'__LOC__' +heredoc +__LOC__ +, $count); + =item HTML::Mason Strings inside C<E<lt>&|/lE<gt>I<...>E<lt>/&E<gt>> and @@ -45,7 +52,7 @@ =item Template Toolkit Strings inside C<[%|l%]...[%END%]> or C<[%|loc%]...[%END%]> -are extracted. +or C<[%FILTER loc%]> or C<[%FILTER l%]> are extracted. =item Text::Template @@ -255,7 +262,7 @@ # Template Toolkit $line = 1; pos($_) = 0; - while (m!\G(.*?\[%-?\s*\|l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { + while (m!\G(.*?\[%-?\s*(?:\|\s*|FILTER\s+)l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?)\s*END\s*-?%\])!sg) { my ($vars, $trim_start, $str, $trim_end) = ($2, $3, $4, $5); $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! $vars =~ s/^\s*\(//; @@ -305,7 +312,7 @@ } # Perl code: - my ($state,$str,$vars,$quo,$heredoc)=(0); + my ($state,$line_offset,$str,$str_part,$vars,$quo,$heredoc)=(0,0); pos($_) = 0; my $orig = 1 + (() = ((my $__ = $_) =~ /\n/g)); @@ -322,28 +329,45 @@ $state == BEG && m/^([\S\(])\s*/gc && do { $state = ( ($1 eq '(') ? PAR : NUL); redo }; + # concat + $state == PAR && defined($str) && m/^(\s*\.\s*)/gc + && do { $line_offset += (() = ((my $__ = $1) =~ /\n/g)); redo }; + + # str_part + $state == PAR && defined($str_part) && do { + if (($quo == QUO1) || ($quo == QUO5) ){ + $str_part =~ s/\\([\\'])/$1/g if ($str_part); # normalize q strings + } + elsif ($quo != QUO6) { + $str_part =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str_part); # normalize qq / qx strings + } + $str .= $str_part; + undef $str_part; undef $quo; + redo; + }; + # begin or end of string $state == PAR && m/^(\')/gc && do { $state = $quo = QUO1; redo }; - $state == QUO1 && m/^([^'\\]+)/gc && do { $str .= $1; redo }; - $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; + $state == QUO1 && m/^([^'\\]+)/gc && do { $str_part .= $1; redo }; + $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; $state == QUO1 && m/^\'/gc && do { $state = PAR; redo }; $state == PAR && m/^\"/gc && do { $state = $quo = QUO2; redo }; - $state == QUO2 && m/^([^"\\]+)/gc && do { $str .= $1; redo }; - $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str .= $1; redo }; + $state == QUO2 && m/^([^"\\]+)/gc && do { $str_part .= $1; redo }; + $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str_part .= $1; redo }; $state == QUO2 && m/^\"/gc && do { $state = PAR; redo }; $state == PAR && m/^\`/gc && do { $state = $quo = QUO3; redo }; - $state == QUO3 && m/^([^\`]*)/gc && do { $str .= $1; redo }; + $state == QUO3 && m/^([^\`]*)/gc && do { $str_part .= $1; redo }; $state == QUO3 && m/^\`/gc && do { $state = PAR; redo }; $state == PAR && m/^qq\{/gc && do { $state = $quo = QUO4; redo }; - $state == QUO4 && m/^([^\}]*)/gc && do { $str .= $1; redo }; + $state == QUO4 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; $state == QUO4 && m/^\}/gc && do { $state = PAR; redo }; $state == PAR && m/^q\{/gc && do { $state = $quo = QUO5; redo }; - $state == QUO5 && m/^([^\}]*)/gc && do { $str .= $1; redo }; + $state == QUO5 && m/^([^\}]*)/gc && do { $str_part .= $1; redo }; $state == QUO5 && m/^\}/gc && do { $state = PAR; redo }; # find heredoc terminator, then get the heredoc and go back to current position @@ -360,7 +384,7 @@ $state == PAR && m/^<<(\w*)/gc && do { $state = HERE; $quo = QUO7; $heredoc = $1; redo }; # jump ahaid and get the heredoc, then s/// also reset the pos and we are back at the current pos - $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str .= $1; redo }; + $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n)$heredoc(\r?\n)//s && do { $state = PAR; $str_part .= $1; $line_offset++; redo }; # end () # @@ -368,15 +392,9 @@ $state == PAR && m/^\s*[\)]/gc && do { $state = NUL; $vars =~ s/[\n\r]//g if ($vars); - if (($quo == QUO1) || ($quo == QUO5) ){ - $str =~ s/\\([\\'])/$1/g if ($str); # normalize q strings - } - elsif ($quo != QUO6) { - $str =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if ($str); # normalize qq / qx strings - } - # heredoc loosing the terminating line, so decrement one more line for heredoc - push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - defined($heredoc), $vars] if ($str); + push @{$entries->{$str}}, [ $file, $line - (() = $str =~ /\n/g) - $line_offset, $vars] if ($str); undef $str; undef $vars; undef $heredoc; + $line_offset = 0; redo; };
Subject: Re: [rt.cpan.org #39057] concat in loc() works now and TT can now use [% FILTER loc %]
Date: Fri, 12 Sep 2008 11:34:00 -0400
To: bug-Locale-Maketext-Lexicon [...] rt.cpan.org
From: Jesse Vincent <jesse [...] fsck.com>
Thanks, Applied. Can you give it a test and tell me if the version I committed to svn looks right? On Sep 7, 2008, at 4:00 PM, Felix Antonius Wilhelm Ostmann via RT wrote: Show quoted text
> Queue: Locale-Maketext-Lexicon > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > > > Here is another patch for Locale::Maketext::Extract with a liddle bit > more pod ... i dont often write pod, dont know how markup right ... > and > hope RT handle the attachment :) > > Jesse via RT schrieb:
>> <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > >> >> >> On Sep 7, 2008, at 3:18 PM, Felix Antonius Wilhelm Ostmann via RT >> wrote: >>
>>> Queue: Locale-Maketext-Lexicon >>> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=39057 > >>> >>> uh, it was so late :) >>> >>> at which point in the docu? i cant find a position where i can >>> incluse >>> such information about that feature :-/
>> >> >> Hmm. >> >> I think just adding more examples to Locale::Maketext::Extract's docs >> is the right thing. >> It's totally ok for you to only add samples for TT and force a mason >> guy to do the mason ones ;) >> >>
> > > --- Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm.orig > 2008-09-07 02:12:33.000000000 +0200 > +++ Locale-Maketext-Lexicon-0.68/lib/Locale/Maketext/Extract.pm > 2008-09-07 21:57:56.000000000 +0200 > @@ -37,6 +37,13 @@ > Valid localization function names are: C<translate>, C<maketext>, > C<gettext>, C<loc>, C<x>, C<_> and C<__>. > > +Concatination of all kind of strings are possible, so you can write > this: > + > +_("here my $voice" . "\n" . 'dont fear my [_1]' . <<'__LOC__' > +heredoc > +__LOC__ > +, $count); > + > =item HTML::Mason > > Strings inside C<E<lt>&|/lE<gt>I<...>E<lt>/&E<gt>> and > @@ -45,7 +52,7 @@ > =item Template Toolkit > > Strings inside C<[%|l%]...[%END%]> or C<[%|loc%]...[%END%]> > -are extracted. > +or C<[%FILTER loc%]> or C<[%FILTER l%]> are extracted. > > =item Text::Template > > @@ -255,7 +262,7 @@ > > # Template Toolkit > $line = 1; pos($_) = 0; > - while (m!\G(.*?\[%-?\s*\|l(?:oc)?(.*?)\s*(-?)%\](.*?)\[%(-?) > \s*END\s*-?%\])!sg) { > + while (m!\G(.*?\[%-?\s*(?:\|\s*|FILTER\s+)l(?:oc)?(.*?)\s*(-?)% > \](.*?)\[%(-?)\s*END\s*-?%\])!sg) { > my ($vars, $trim_start, $str, $trim_end) = ($2, $3, $4, $5); > $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! > $vars =~ s/^\s*\(//; > @@ -305,7 +312,7 @@ > } > > # Perl code: > - my ($state,$str,$vars,$quo,$heredoc)=(0); > + my ($state,$line_offset,$str,$str_part,$vars,$quo, > $heredoc)=(0,0); > pos($_) = 0; > my $orig = 1 + (() = ((my $__ = $_) =~ /\n/g)); > > @@ -322,28 +329,45 @@ > $state == BEG && m/^([\S\(])\s*/gc > && do { $state = ( ($1 eq '(') ? PAR : NUL); > redo }; > > + # concat > + $state == PAR && defined($str) && m/^(\s*\.\s*)/gc > + && do { $line_offset += (() = ((my $__ = $1) > =~ /\n/g)); redo }; > + > + # str_part > + $state == PAR && defined($str_part) && do { > + if (($quo == QUO1) || ($quo == QUO5) ){ > + $str_part =~ s/\\([\\'])/$1/g if ($str_part); # > normalize q strings > + } > + elsif ($quo != QUO6) { > + $str_part =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if > ($str_part); # normalize qq / qx strings > + } > + $str .= $str_part; > + undef $str_part; undef $quo; > + redo; > + }; > + > # begin or end of string > $state == PAR && m/^(\')/gc && do { $state = $quo = > QUO1; redo }; > - $state == QUO1 && m/^([^'\\]+)/gc && do { $str .= $1; > redo }; > - $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str .= $1; > redo }; > + $state == QUO1 && m/^([^'\\]+)/gc && do { $str_part .= > $1; redo }; > + $state == QUO1 && m/^((?:\\.)+)/gcs && do { $str_part .= > $1; redo }; > $state == QUO1 && m/^\'/gc && do { $state = > PAR; redo }; > > $state == PAR && m/^\"/gc && do { $state = $quo = > QUO2; redo }; > - $state == QUO2 && m/^([^"\\]+)/gc && do { $str .= $1; > redo }; > - $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str .= $1; > redo }; > + $state == QUO2 && m/^([^"\\]+)/gc && do { $str_part .= > $1; redo }; > + $state == QUO2 && m/^((?:\\.)+)/gcs && do { $str_part .= > $1; redo }; > $state == QUO2 && m/^\"/gc && do { $state = > PAR; redo }; > > $state == PAR && m/^\`/gc && do { $state = $quo = > QUO3; redo }; > - $state == QUO3 && m/^([^\`]*)/gc && do { $str .= > $1; redo }; > + $state == QUO3 && m/^([^\`]*)/gc && do { $str_part .= > $1; redo }; > $state == QUO3 && m/^\`/gc && do { $state = > PAR; redo }; > > $state == PAR && m/^qq\{/gc && do { $state = $quo = > QUO4; redo }; > - $state == QUO4 && m/^([^\}]*)/gc && do { $str .= > $1; redo }; > + $state == QUO4 && m/^([^\}]*)/gc && do { $str_part .= > $1; redo }; > $state == QUO4 && m/^\}/gc && do { $state = > PAR; redo }; > > > $state == PAR && m/^q\{/gc && do { $state = $quo = > QUO5; redo }; > - $state == QUO5 && m/^([^\}]*)/gc && do { $str .= > $1; redo }; > + $state == QUO5 && m/^([^\}]*)/gc && do { $str_part .= > $1; redo }; > $state == QUO5 && m/^\}/gc && do { $state = > PAR; redo }; > > # find heredoc terminator, then get the heredoc and go back > to current position > @@ -360,7 +384,7 @@ > $state == PAR && m/^<<(\w*)/gc && do { $state = HERE; > $quo = QUO7; $heredoc = $1; redo }; > > # jump ahaid and get the heredoc, then s/// also reset the > pos and we are back at the current pos > - $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n) > $heredoc(\r?\n)//s && do { $state = PAR; $str .= $1; redo }; > + $state == HERE && m/^.*\r?\n/gc && s/\G(.*?\r?\n) > $heredoc(\r?\n)//s && do { $state = PAR; $str_part .= $1; > $line_offset++; redo }; > > # end () > # > @@ -368,15 +392,9 @@ > $state == PAR && m/^\s*[\)]/gc && do { > $state = NUL; > $vars =~ s/[\n\r]//g if ($vars); > - if (($quo == QUO1) || ($quo == QUO5) ){ > - $str =~ s/\\([\\'])/$1/g if ($str); # normalize q > strings > - } > - elsif ($quo != QUO6) { > - $str =~ s/(\\(?:[0x]..|c?.))/"qq($1)"/eeg if > ($str); # normalize qq / qx strings > - } > - # heredoc loosing the terminating line, so decrement > one more line for heredoc > - push @{$entries->{$str}}, [ $file, $line - (() = $str > =~ /\n/g) - defined($heredoc), $vars] if ($str); > + push @{$entries->{$str}}, [ $file, $line - (() = $str > =~ /\n/g) - $line_offset, $vars] if ($str); > undef $str; undef $vars; undef $heredoc; > + $line_offset = 0; > redo; > }; >
On Sat Sep 06 21:40:27 2008, Sadrak wrote: Show quoted text
> now it is possible to concat strings in loc() and in TT you can use [% > FILTER loc %]
Thanks for your patch. The TT parser has been completely rewritten and now supports the forms you mention above. clint
On Tue Oct 28 15:24:32 2008, DRTECH wrote: Show quoted text
> On Sat Sep 06 21:40:27 2008, Sadrak wrote:
> > now it is possible to concat strings in loc() and in TT you can use [% > > FILTER loc %]
> > Thanks for your patch. The TT parser has been completely rewritten and > now supports the forms you mention above. > > clint
On Wed Oct 29 04:55:47 2008, DRTECH wrote: Show quoted text
> On Tue Oct 28 15:24:32 2008, DRTECH wrote:
> > On Sat Sep 06 21:40:27 2008, Sadrak wrote:
> > > now it is possible to concat strings in loc() and in TT you can use [% > > > FILTER loc %]
> > > > Thanks for your patch. The TT parser has been completely rewritten and > > now supports the forms you mention above. > >
I didn't realise that your Perl parser changes weren't in the current version. They have been included in version 0.74 now thanks Clint
On Sat Nov 22 15:51:03 2008, DRTECH wrote: Show quoted text
> On Wed Oct 29 04:55:47 2008, DRTECH wrote:
> > On Tue Oct 28 15:24:32 2008, DRTECH wrote:
> > > On Sat Sep 06 21:40:27 2008, Sadrak wrote:
> > > > now it is possible to concat strings in loc() and in TT you can
use [% Show quoted text
> > > > FILTER loc %]
> > > > > > Thanks for your patch. The TT parser has been completely rewritten and > > > now supports the forms you mention above. > > >
> > I didn't realise that your Perl parser changes weren't in the current > version. They have been included in version 0.74 now > > thanks > > Clint >