Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

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: 68864
Status: resolved
Priority: 0/
Queue: Locale-Maketext-Lexicon

People
Owner: Nobody in particular
Requestors: asimon [...] cpan.org
Cc: cpan [...] audreyt.org
vincent.delove [...] ciril.fr
AdminCc:

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

Attachments


CC: cpan [...] audreyt.org, vincent.delove [...] ciril.fr
Subject: Mason plugin to extract strings from Mason 2
Hi all, we are using Locale-Maketext-Lexicon to do localization in our web application which runs under Mason 2 (http://search.cpan.org/~jswartz/Mason-2.07/). HTML::Mason (Mason 1) and Mason (Mason 2) are not compatible about the filtering syntax : - in HTML::Mason one does : <&| /path/to/comp &> the content </&> - in Mason one now does : <% $.myfilter { %> the content </%> In fact, Mason documentation is clear about this (http://search.cpan.org/~jswartz/Mason-2.07/lib/Mason/Manual/UpgradingFromMason1.pod) : "Components with content syntax has been eliminated; use the CompCall filter instead." So, I've complete Locale/Maketext/Extract/Plugin/Mason.pm source to take care of Mason (2) syntax , please see the attached patch. I've tested and all is ok with Mason (2) template files. PS: In the code I've hard coded filter function name with "floc" or "fl" to do not run into collision with col("...") regexp parser (from Locale::Maketext::Extract::Plugin::Perl). I remains available to help you correct and complete this module to take care of Mason (2). Alex.
Subject: extract-mason2.patch
diff -ru Locale-Maketext-Lexicon-0.86.orig/lib/Locale/Maketext/Extract/Plugin/Mason.pm Locale-Maketext-Lexicon-0.86/lib/Locale/Maketext/Extract/Plugin/Mason.pm --- Locale-Maketext-Lexicon-0.86.orig/lib/Locale/Maketext/Extract/Plugin/Mason.pm 2010-08-10 14:46:06.000000000 +0200 +++ Locale-Maketext-Lexicon-0.86/lib/Locale/Maketext/Extract/Plugin/Mason.pm 2011-06-16 13:20:03.000000000 +0200 @@ -5,7 +5,7 @@ =head1 NAME -Locale::Maketext::Extract::Plugin::Mason - Mason format parser +Locale::Maketext::Extract::Plugin::Mason - HTML::Mason (aka Mason 1) and Mason (aka Mason 2) format parser =head1 SYNOPSIS @@ -26,8 +26,13 @@ =head1 VALID FORMATS +HTML::Mason (aka Mason 1) Strings inside <&|/l>...</&> and <&|/loc>...</&> are extracted. +Mason (aka Mason 2) +Strings inside <% $.floc { %>...</%> or <% $.fl { %>...</%> or +<% $self->floc { %>...</%> or <% $self->fl { %>...</%> are extracted. + =head1 KNOWN FILE TYPES =over 4 @@ -49,12 +54,18 @@ my $line = 1; - # HTML::Mason - + # HTML::Mason (aka Mason 1) while (m!\G(.*?<&\|/l(?:oc)?(.*?)&>(.*?)</&>)!sg) { my ($vars, $str) = ($2, $3); $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! - $self->add_entry($str, $line, $vars ); + $self->add_entry($str, $line, $vars ); + } + + # Mason (aka Mason 2) + while (m!\G(.*?<%[ ]*\$(\.|self->)fl(?:oc)?(\((.*?)\))?[ ]*{[ ]*%>(.*?)</%>)!sg) { + my ($vars, $str) = ($4, $5); + $line += ( () = ($2 =~ /\n/g) ); # cryptocontext! + $self->add_entry($str, $line, $vars ); } } @@ -119,4 +130,4 @@ =cut -1; \ No newline at end of file +1;
Download (untitled) / with headers
text/plain 173b
Hi Alex Many thanks for the patch Could you also provide a patch adding some tests for Mason2? Once I've got those, I'll be happy to do a new release many thanks Clint
Download (untitled) / with headers
text/plain 316b
Hi Clint, here is my final patch which includes : - a fix in regexp to extract all cases of HTML::Mason syntax - the repexp to extract Mason (aka Mason 2) syntax - some tests to check this modules with HTML::mason and Mason examples Please let me know if it's ok for you ? Best regards, Alex.
Subject: fix-html-mason-regexp+extract-mason2+tests.patch
diff -ru Locale-Maketext-Lexicon-0.86.orig//lib/Locale/Maketext/Extract/Plugin/Mason.pm Locale-Maketext-Lexicon-0.86//lib/Locale/Maketext/Extract/Plugin/Mason.pm --- Locale-Maketext-Lexicon-0.86.orig//lib/Locale/Maketext/Extract/Plugin/Mason.pm 2010-08-10 14:46:06.000000000 +0200 +++ Locale-Maketext-Lexicon-0.86//lib/Locale/Maketext/Extract/Plugin/Mason.pm 2011-06-20 16:30:04.000000000 +0200 @@ -5,7 +5,7 @@ =head1 NAME -Locale::Maketext::Extract::Plugin::Mason - Mason format parser +Locale::Maketext::Extract::Plugin::Mason - HTML::Mason (aka Mason 1) and Mason (aka Mason 2) format parser =head1 SYNOPSIS @@ -26,7 +26,12 @@ =head1 VALID FORMATS -Strings inside <&|/l>...</&> and <&|/loc>...</&> are extracted. +HTML::Mason (aka Mason 1) + Strings inside <&|/l>...</&> and <&|/loc>...</&> are extracted. + +Mason (aka Mason 2) +Strings inside <% $.floc { %>...</%> or <% $.fl { %>...</%> or +<% $self->floc { %>...</%> or <% $self->fl { %>...</%> are extracted. =head1 KNOWN FILE TYPES @@ -49,12 +54,18 @@ my $line = 1; - # HTML::Mason - - while (m!\G(.*?<&\|/l(?:oc)?(.*?)&>(.*?)</&>)!sg) { + # HTML::Mason (aka Mason 1) + while (m!\G(.*?<&\|[ ]*/l(?:oc)?(?:[ ]*,[ ]*(.*?))?[ ]*&>(.*?)</&>)!sg) { my ($vars, $str) = ($2, $3); $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! - $self->add_entry($str, $line, $vars ); + $self->add_entry($str, $line, $vars ); + } + + # Mason (aka Mason 2) + while (m!\G(.*?<%[ ]*(?:\$(?:\.|self->))fl(?:oc)?(?:[ ]*\((.*?)\))?[ ]*{[ ]*%>(.*?)</%>)!sg) { + my ($vars, $str) = ($2, $3); + $line += ( () = ($1 =~ /\n/g) ); # cryptocontext! + $self->add_entry($str, $line, $vars ); } } @@ -119,4 +130,4 @@ =cut -1; \ No newline at end of file +1; diff -ru Locale-Maketext-Lexicon-0.86.orig//t/5-extract.t Locale-Maketext-Lexicon-0.86//t/5-extract.t --- Locale-Maketext-Lexicon-0.86.orig//t/5-extract.t 2010-08-10 14:46:14.000000000 +0200 +++ Locale-Maketext-Lexicon-0.86//t/5-extract.t 2011-06-20 16:30:15.000000000 +0200 @@ -1,7 +1,7 @@ #! /usr/bin/perl -w use lib '../lib'; use strict; -use Test::More tests => 64; +use Test::More tests => 76; use_ok('Locale::Maketext::Extract'); my $Ext = Locale::Maketext::Extract->new(); @@ -33,6 +33,434 @@ #### END WRAPPING TESTS ############ $Ext->{wrap} = 0; + +#### BEGIN HTML::Mason (aka Mason 1) TESTS ############ +SKIP: { + skip( 'HTML::Mason unavailable', 5 ) unless eval { require HTML::Mason }; + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason simple" ); +<&|/l&>string1</&> +<&|/loc&>string2</&> +__EXAMPLE__ +#: :1 +msgid "string1" +msgstr "" + +#: :2 +msgid "string2" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason simple with spaces" ); +<&| /l&>string1</&> +<&|/l &>string2</&> +<&| /l &>string3</&> +<&| /loc&>string4</&> +<&|/loc &>string5</&> +<&| /loc &>string6</&> +__EXAMPLE__ +#: :1 +msgid "string1" +msgstr "" + +#: :2 +msgid "string2" +msgstr "" + +#: :3 +msgid "string3" +msgstr "" + +#: :4 +msgid "string4" +msgstr "" + +#: :5 +msgid "string5" +msgstr "" + +#: :6 +msgid "string6" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason one argument" ); +<&|/l,arg1=>value1&>string1</&> +<&|/loc,arg1=>value1&>string2</&> +__EXAMPLE__ +#. (arg1=>value1) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1) +#: :2 +msgid "string2" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason one argument with spaces" ); +<&|/l, arg1=>value1&>string1</&> +<&|/loc, arg1=>value1&>string2</&> +<&|/l ,arg1=>value1&>string3</&> +<&|/loc ,arg1=>value1&>string4</&> +<&|/l , arg1=>value1&>string5</&> +<&|/loc , arg1=>value1&>string6</&> +<&| /l , arg1=>value1 &>string7</&> +<&| /loc , arg1=>value1 &>string8</&> +__EXAMPLE__ +#. (arg1=>value1) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1) +#: :2 +msgid "string2" +msgstr "" + +#. (arg1=>value1) +#: :3 +msgid "string3" +msgstr "" + +#. (arg1=>value1) +#: :4 +msgid "string4" +msgstr "" + +#. (arg1=>value1) +#: :5 +msgid "string5" +msgstr "" + +#. (arg1=>value1) +#: :6 +msgid "string6" +msgstr "" + +#. (arg1=>value1) +#: :7 +msgid "string7" +msgstr "" + +#. (arg1=>value1) +#: :8 +msgid "string8" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason two arguments" ); +<&|/l,arg1=>value1,arg2=>value2&>string1</&> +<&|/loc,arg1=>value1,arg2=>value2&>string2</&> +__EXAMPLE__ +#. (arg1=>value1,arg2=>value2) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :2 +msgid "string2" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "HTML::Mason two arguments with spaces" ); +<&|/l ,arg1=>value1,arg2=>value2&>string1</&> +<&|/loc ,arg1=>value1,arg2=>value2&>string2</&> +<&|/l , arg1=>value1,arg2=>value2&>string3</&> +<&|/loc , arg1=>value1,arg2=>value2&>string4</&> +<&|/l , arg1=>value1, arg2=>value2&>string5</&> +<&|/loc , arg1=>value1, arg2=>value2&>string6</&> +<&| /l , arg1=>value1, arg2=>value2 &>string7</&> +<&| /loc , arg1=>value1, arg2=>value2 &>string8</&> +__EXAMPLE__ +#. (arg1=>value1,arg2=>value2) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :2 +msgid "string2" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :3 +msgid "string3" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :4 +msgid "string4" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :5 +msgid "string5" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :6 +msgid "string6" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :7 +msgid "string7" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :8 +msgid "string8" +msgstr "" +__EXPECTED__ + +} +#### END HTML::Mason (aka Mason 1) TESTS ############ + + +#### BEGIN Mason (aka Mason 2) TESTS ############ +SKIP: { + skip( 'Mason unavailable', 5 ) unless eval { require Mason }; + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason simple" ); +<%$.fl {%>string1</%> +<%$.floc {%>string2</%> +<%$self->fl {%>string3</%> +<%$self->floc {%>string4</%> +__EXAMPLE__ +#: :1 +msgid "string1" +msgstr "" + +#: :2 +msgid "string2" +msgstr "" + +#: :3 +msgid "string3" +msgstr "" + +#: :4 +msgid "string4" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason simple with spaces" ); +<% $.fl {%>string1</%> +<% $.floc {%>string2</%> +<% $self->fl {%>string3</%> +<% $self->floc {%>string4</%> +<% $.fl { %>string5</%> +<% $.floc { %>string6</%> +<% $self->fl { %>string7</%> +<% $self->floc { %>string8</%> +__EXAMPLE__ +#: :1 +msgid "string1" +msgstr "" + +#: :2 +msgid "string2" +msgstr "" + +#: :3 +msgid "string3" +msgstr "" + +#: :4 +msgid "string4" +msgstr "" + +#: :5 +msgid "string5" +msgstr "" + +#: :6 +msgid "string6" +msgstr "" + +#: :7 +msgid "string7" +msgstr "" + +#: :8 +msgid "string8" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason one argument" ); +<%$.fl(arg1=>value1){%>string1</%> +<%$.floc(arg1=>value1){%>string2</%> +<%$self->fl(arg1=>value1){%>string3</%> +<%$self->floc(arg1=>value1){%>string4</%> +__EXAMPLE__ +#. (arg1=>value1) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1) +#: :2 +msgid "string2" +msgstr "" + +#. (arg1=>value1) +#: :3 +msgid "string3" +msgstr "" + +#. (arg1=>value1) +#: :4 +msgid "string4" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason one argument with spaces" ); +<% $.fl(arg1=>value1){%>string1</%> +<% $.floc(arg1=>value1){%>string2</%> +<% $.fl(arg1=>value1) {%>string3</%> +<% $.floc(arg1=>value1) {%>string4</%> +<% $.fl(arg1=>value1) { %>string5</%> +<% $.floc(arg1=>value1) { %>string6</%> +__EXAMPLE__ +#. (arg1=>value1) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1) +#: :2 +msgid "string2" +msgstr "" + +#. (arg1=>value1) +#: :3 +msgid "string3" +msgstr "" + +#. (arg1=>value1) +#: :4 +msgid "string4" +msgstr "" + +#. (arg1=>value1) +#: :5 +msgid "string5" +msgstr "" + +#. (arg1=>value1) +#: :6 +msgid "string6" +msgstr "" +__EXPECTED__ + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason two arguments" ); +<% $.fl(arg1=>value1,arg2=>value2){%>string1</%> +<% $.floc(arg1=>value1,arg2=>value2){%>string2</%> +<%$self->fl(arg1=>value1,arg2=>value2){%>string3</%> +<%$self->floc(arg1=>value1,arg2=>value2){%>string4</%> +__EXAMPLE__ +#. (arg1=>value1,arg2=>value2) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :2 +msgid "string2" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :3 +msgid "string3" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :4 +msgid "string4" +msgstr "" +__EXPECTED__ + + + + write_po_ok( <<'__EXAMPLE__' => <<'__EXPECTED__', "Mason two arguments with spaces" ); +<%$.fl(arg1=>value1,arg2=>value2){%>string1</%> +<%$.floc(arg1=>value1,arg2=>value2){%>string2</%> +<% $.fl (arg1=>value1,arg2=>value2){%>string3</%> +<% $.floc (arg1=>value1,arg2=>value2){%>string4</%> +<% $.fl (arg1=>value1, arg2=>value2){%>string5</%> +<% $.floc (arg1=>value1, arg2=>value2){%>string6</%> +<% $.fl (arg1=>value1, arg2=>value2) {%>string7</%> +<% $.floc (arg1=>value1, arg2=>value2) {%>string8</%> +<% $.fl (arg1=>value1, arg2=>value2) { %>string9</%> +<% $.floc (arg1=>value1, arg2=>value2) { %>string10</%> +__EXAMPLE__ +#. (arg1=>value1,arg2=>value2) +#: :1 +msgid "string1" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :10 +msgid "string10" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :2 +msgid "string2" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :3 +msgid "string3" +msgstr "" + +#. (arg1=>value1,arg2=>value2) +#: :4 +msgid "string4" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :5 +msgid "string5" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :6 +msgid "string6" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :7 +msgid "string7" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :8 +msgid "string8" +msgstr "" + +#. (arg1=>value1, arg2=>value2) +#: :9 +msgid "string9" +msgstr "" +__EXPECTED__ + +} +#### END Mason (aka Mason 2) TESTS ############ + + #### BEGIN FORMFU TESTS ############ SKIP: { skip( 'YAML.pm unavailable', 5 ) unless eval { require YAML };
Download (untitled) / with headers
text/plain 133b
Hi Alex Show quoted text
> > Please let me know if it's ok for you ? > Best regards, > Alex.
Many thank - added and released in version 0.87


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.