You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by RobertCZ <ro...@robert.cz> on 2004/12/12 14:38:13 UTC
Urgent: MsgIdExtract problem
Hi,
I'm stuck with this MsgIdExtract.pm problem: [= Hello World =] gives
error
[582]ERR: 24: Error in Perl code: Can't locate object method "Hello"
via package "World" (perhaps you forgot to load "World"?) at
/home/www/phl/doc/accom.html line 31.
when extracting messages. I believe in some older version quotes like
[= 'Hello World' =] would fix it, but in RC2 it just prints it with
quotes 'Hello World'.
The problem is perhaps this definition
'Embperl output msg id' => {
'text' => '[=',
'end' => '=]',
'unescape' => 1,
'procinfo' => {
embperl => {
perlcode =>
[
'$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
],
removenode => 4,
compilechilds => 0,
}
},
},
) ;
but I don't see how scalar(%#0%) modify into "whole text between [= and
=]" Would you please advice? Thank you.
- Robert
PS Another problem: $epreq->('XXX') is ignored completely by this
extract syntax
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Multilingual support / was Re: Urgent: MsgIdExtract problem
Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:
>Thanks for your feedback. I try to bring the things into the 2.0 release.
>
>
>>- MsgIdExtract ignores [- $epreq->gettext(expr) -] I don't
>>know how to modify the syntax, but it's clearly a bug
>>
>>
>
>MsgIdExtract at the moment only knows about [= =], maybe I can try to parse
>it out gettext as well, but it will only work for literal strings. I will
>think about a solution.
>
>
I believe literal strings would be enough, I was planning something like
sprintf $epreq->('%d records founds'), $found;
which would then generate "Nalezeno 32 zaznamu" or "32 records found"
etc... so the gettext'ed string itself is just a literal string
PS What about that additional quotes after running extract and using
deafult message if translated string is empty/undef instaed of missing
key only?
PS2 I'm already using it in my two big projects and it's really REALLY
nice ;-)
>>-----Original Message-----
>>From: RobertCZ [mailto:robert@robert.cz]
>>Sent: Wednesday, December 15, 2004 12:49 PM
>>To: embperl@perl.apache.org
>>Cc: Gerald Richter
>>Subject: Multilingual support / was Re: Urgent: MsgIdExtract problem
>>
>>Gerald Richter wrote:
>>
>>
>>'$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
>> ($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>>
>>
>>
>> Try to change %#0% to %#\'0%
>>
>>
>>
>>OK, now I got it working and it's really cool (with the
>>exception of the last couple of bugs). Here are my comments
>>(relevant for 2.0RC2):
>>
>>
>>- I changed MsgIdExtract syntax from %#0% to %#\'0%, now it
>>correctly extracts more complex expressions, but it adds
>>superflous quotes and a space to the extracted expressions,
>>it looks like this '\'Test \'' => '', This can be hacked in
>>the extract script with something like
>>
>>foreach my $fn (@files) {
>>...
>> Embperl::Execute ({use_env => 1, use_redirect_env => 1,
>>syntax => 'MsgIdExtract', inputfile => $fn, output => \$out,
>>errors => \@errors}) ; ...
>>}
>>my @correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
>>%Embperl::Syntax::MsgIdExtract::Ids;
>>
>>but I think it's a bug
>>
>>
>>- MsgIdExtract ignores [- $epreq->gettext(expr) -] I don't
>>know how to modify the syntax, but it's clearly a bug
>>
>>
>>- when messages are dumped with $Data::Dumper::Useqq = 1 it
>>break 8bit chars (dump as octal, but translators would go mad
>>should they see it)
>>
>>
>>- I find it more practical to dump sorted messages with
>>something like $Data::Dumper::Sortkeys = \&{ sub {[ sort {
>>$a cmp $b } keys %{$_[0]} ]} }
>>
>>
>>- app file must delete empty (missing) translations to force
>>EP use message in the default language, this is quite
>>impractical because translators need it in the dictionary
>>file and so during the development I need to modify the
>>dictionary either for EP or for translators. Now I delete it
>>in app file but it's stupid performance-wise
>>
>>- Robert
>>
>>-------------------------------------
>>
>>Just in case somebody needs it, below are necessary files
>>
>>_app.eo
>>
>>-------------------------------------
>>
>>@ISA = ('Embperl::App') ;
>>
>>sub init {
>> my $self = shift ;
>> my $r = $self->curr_req ;
>> my $fdat = $r->thread->form_hash;
>> my $lang = $fdat->{lang} || 'en' ;
>> my %messages = %{ do '/home/www/germic/etc/dict/dict.dump' };
>>
>> foreach my $l (keys %messages) {
>> foreach my $t (keys %{ $messages{$l} }) {
>> delete $messages{$l}{$t} unless $messages{$l}{$t};
>> }
>> }
>>
>>#use Data::Dumper; print STDERR "\n\n", Dumper(\%messages), "\n\n";
>>
>> push @{$r->messages}, $messages{$lang} ;
>> push @{$r->default_messages}, $messages{'en'} if
>>($lang ne 'en') ;
>>
>> return 0;
>>
>>}
>>
>>1 ;
>>
>>-------------------------------------
>>
>>extract
>>
>>-------------------------------------
>>
>>BEGIN
>> {
>> %Embperl::initparam = (use_env => 1, use_redirect_env => 1) ;
>> $ENV{EMBPERL_SESSION_HANDLER_CLASS} = 'no' ;
>> }
>>
>>use Embperl;
>>use Data::Dumper ;
>>
>>use strict;
>>use vars qw{$srcpath $dictpath @files @languages $msgids
>>@correct_keys};
>>
>>$srcpath = '/home/www/germic';
>>$dictpath = '/home/www/germic/etc/dict';
>>@files = split ' ', `find $srcpath -name *.html
>>-printf "%p " -or -name *.eo -printf "%p "`;
>>@languages = qw(cz de); # en not listed, it's default!
>>
>>$msgids = do "$dictpath/dict.dump" ;
>>die $@ if ($@) ;
>>#print Dumper($msgids);
>>
>>foreach my $fn (@files) {
>> my ( $out, @errors );
>> Embperl::Execute ({use_env => 1, use_redirect_env => 1,
>>syntax => 'MsgIdExtract', inputfile => $fn, output => \$out,
>>errors => \@errors}) ;
>> if (@errors) {
>> print join ("\n", @errors) ;
>> last ;
>> }
>>}
>>#print Dumper(\%Embperl::Syntax::MsgIdExtract::Ids);
>>
>>@correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
>>%Embperl::Syntax::MsgIdExtract::Ids;
>>#print Dumper(\@correct_keys);
>>
>>foreach my $lang (@languages) {
>> foreach my $k (@correct_keys) {
>> $msgids -> {en}{$k} = $k ;
>> $msgids -> {$lang}{$k} = '' if (!exists $msgids ->
>>{$lang}{$k}) ;
>> }
>>}
>>#print Dumper($msgids);
>>
>>rename "$dictpath/dict.dump", "$dictpath/dict.bak" ; open FH,
>>">$dictpath/dict.dump" or die "Cannot open
>>$dictpath/dict.dump ($!)" ; # $Data::Dumper::Indent = 1 ; #
>>default is nicer # $Data::Dumper::Useqq = 1 ; # breaks 8bit
>>chars $Data::Dumper::Sortkeys = \&{ sub {[ sort { $a cmp $b
>>} keys %{$_[0]} ]} } ; # more practical print FH
>>Data::Dumper -> Dump ([$msgids], ['msgids']) ; close FH ;
>>
>>-------------------------------------
>>
>>test
>>
>>-------------------------------------
>>
>><h1>trans test</h1>
>>
>><p>Test: <b>[= Test =]</b>
>><p>Hi!: <b>[= Hi! =]</b>
>><p>Thank You!: <b>[= Thank You! =]</b>
>><p>Athos, Porthos, Aramis & d'Artagnan: <b>[= Athos,
>>Porthos, Aramis & d'Artagnan =]</b> <p>How's life?: <b>[+
>>$epreq->gettext(qq{How's life?}) +]<b>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>
RE: Multilingual support / was Re: Urgent: MsgIdExtract problem
Posted by Gerald Richter <ri...@ecos.de>.
Robert,
Thanks for your feedback. I try to bring the things into the 2.0 release.
> - MsgIdExtract ignores [- $epreq->gettext(expr) -] I don't
> know how to modify the syntax, but it's clearly a bug
MsgIdExtract at the moment only knows about [= =], maybe I can try to parse
it out gettext as well, but it will only work for literal strings. I will
think about a solution.
Gerald
---------------------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
> -----Original Message-----
> From: RobertCZ [mailto:robert@robert.cz]
> Sent: Wednesday, December 15, 2004 12:49 PM
> To: embperl@perl.apache.org
> Cc: Gerald Richter
> Subject: Multilingual support / was Re: Urgent: MsgIdExtract problem
>
> Gerald Richter wrote:
>
>
> '$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
> ($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>
>
>
> Try to change %#0% to %#\'0%
>
>
>
> OK, now I got it working and it's really cool (with the
> exception of the last couple of bugs). Here are my comments
> (relevant for 2.0RC2):
>
>
> - I changed MsgIdExtract syntax from %#0% to %#\'0%, now it
> correctly extracts more complex expressions, but it adds
> superflous quotes and a space to the extracted expressions,
> it looks like this '\'Test \'' => '', This can be hacked in
> the extract script with something like
>
> foreach my $fn (@files) {
> ...
> Embperl::Execute ({use_env => 1, use_redirect_env => 1,
> syntax => 'MsgIdExtract', inputfile => $fn, output => \$out,
> errors => \@errors}) ; ...
> }
> my @correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
> %Embperl::Syntax::MsgIdExtract::Ids;
>
> but I think it's a bug
>
>
> - MsgIdExtract ignores [- $epreq->gettext(expr) -] I don't
> know how to modify the syntax, but it's clearly a bug
>
>
> - when messages are dumped with $Data::Dumper::Useqq = 1 it
> break 8bit chars (dump as octal, but translators would go mad
> should they see it)
>
>
> - I find it more practical to dump sorted messages with
> something like $Data::Dumper::Sortkeys = \&{ sub {[ sort {
> $a cmp $b } keys %{$_[0]} ]} }
>
>
> - app file must delete empty (missing) translations to force
> EP use message in the default language, this is quite
> impractical because translators need it in the dictionary
> file and so during the development I need to modify the
> dictionary either for EP or for translators. Now I delete it
> in app file but it's stupid performance-wise
>
> - Robert
>
> -------------------------------------
>
> Just in case somebody needs it, below are necessary files
>
> _app.eo
>
> -------------------------------------
>
> @ISA = ('Embperl::App') ;
>
> sub init {
> my $self = shift ;
> my $r = $self->curr_req ;
> my $fdat = $r->thread->form_hash;
> my $lang = $fdat->{lang} || 'en' ;
> my %messages = %{ do '/home/www/germic/etc/dict/dict.dump' };
>
> foreach my $l (keys %messages) {
> foreach my $t (keys %{ $messages{$l} }) {
> delete $messages{$l}{$t} unless $messages{$l}{$t};
> }
> }
>
> #use Data::Dumper; print STDERR "\n\n", Dumper(\%messages), "\n\n";
>
> push @{$r->messages}, $messages{$lang} ;
> push @{$r->default_messages}, $messages{'en'} if
> ($lang ne 'en') ;
>
> return 0;
>
> }
>
> 1 ;
>
> -------------------------------------
>
> extract
>
> -------------------------------------
>
> BEGIN
> {
> %Embperl::initparam = (use_env => 1, use_redirect_env => 1) ;
> $ENV{EMBPERL_SESSION_HANDLER_CLASS} = 'no' ;
> }
>
> use Embperl;
> use Data::Dumper ;
>
> use strict;
> use vars qw{$srcpath $dictpath @files @languages $msgids
> @correct_keys};
>
> $srcpath = '/home/www/germic';
> $dictpath = '/home/www/germic/etc/dict';
> @files = split ' ', `find $srcpath -name *.html
> -printf "%p " -or -name *.eo -printf "%p "`;
> @languages = qw(cz de); # en not listed, it's default!
>
> $msgids = do "$dictpath/dict.dump" ;
> die $@ if ($@) ;
> #print Dumper($msgids);
>
> foreach my $fn (@files) {
> my ( $out, @errors );
> Embperl::Execute ({use_env => 1, use_redirect_env => 1,
> syntax => 'MsgIdExtract', inputfile => $fn, output => \$out,
> errors => \@errors}) ;
> if (@errors) {
> print join ("\n", @errors) ;
> last ;
> }
> }
> #print Dumper(\%Embperl::Syntax::MsgIdExtract::Ids);
>
> @correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
> %Embperl::Syntax::MsgIdExtract::Ids;
> #print Dumper(\@correct_keys);
>
> foreach my $lang (@languages) {
> foreach my $k (@correct_keys) {
> $msgids -> {en}{$k} = $k ;
> $msgids -> {$lang}{$k} = '' if (!exists $msgids ->
> {$lang}{$k}) ;
> }
> }
> #print Dumper($msgids);
>
> rename "$dictpath/dict.dump", "$dictpath/dict.bak" ; open FH,
> ">$dictpath/dict.dump" or die "Cannot open
> $dictpath/dict.dump ($!)" ; # $Data::Dumper::Indent = 1 ; #
> default is nicer # $Data::Dumper::Useqq = 1 ; # breaks 8bit
> chars $Data::Dumper::Sortkeys = \&{ sub {[ sort { $a cmp $b
> } keys %{$_[0]} ]} } ; # more practical print FH
> Data::Dumper -> Dump ([$msgids], ['msgids']) ; close FH ;
>
> -------------------------------------
>
> test
>
> -------------------------------------
>
> <h1>trans test</h1>
>
> <p>Test: <b>[= Test =]</b>
> <p>Hi!: <b>[= Hi! =]</b>
> <p>Thank You!: <b>[= Thank You! =]</b>
> <p>Athos, Porthos, Aramis & d'Artagnan: <b>[= Athos,
> Porthos, Aramis & d'Artagnan =]</b> <p>How's life?: <b>[+
> $epreq->gettext(qq{How's life?}) +]<b>
>
>
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Multilingual support / was Re: Urgent: MsgIdExtract problem
Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:
>I have fixed/changed the points you requested in your mail below. It's now
>in the CVS, you might give it a try...
>
>
Great, thanks, I'm going to test it, but I remember there were some
special procedure necessary to use CVS version for EP2 and docs
http://perl.apache.org/embperl/pod/doc/CVS.htm is empty - so please
where can I get CVS tarball and is there something special to do to install?
- Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Multilingual support / was Re: Urgent: MsgIdExtract problem
Posted by Gerald Richter <ri...@ecos.de>.
Hi Robert,
I have fixed/changed the points you requested in your mail below. It's now
in the CVS, you might give it a try...
Gerald
> -----Original Message-----
> From: RobertCZ [mailto:robert@robert.cz]
> Sent: Wednesday, December 15, 2004 12:49 PM
> To: embperl@perl.apache.org
> Cc: Gerald Richter
> Subject: Multilingual support / was Re: Urgent: MsgIdExtract problem
>
> Gerald Richter wrote:
>
>
> '$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
> ($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>
>
>
> Try to change %#0% to %#\'0%
>
>
>
> OK, now I got it working and it's really cool (with the
> exception of the last couple of bugs). Here are my comments
> (relevant for 2.0RC2):
>
>
> - I changed MsgIdExtract syntax from %#0% to %#\'0%, now it
> correctly extracts more complex expressions, but it adds
> superflous quotes and a space to the extracted expressions,
> it looks like this '\'Test \'' => '', This can be hacked in
> the extract script with something like
>
> foreach my $fn (@files) {
> ...
> Embperl::Execute ({use_env => 1, use_redirect_env => 1,
> syntax => 'MsgIdExtract', inputfile => $fn, output => \$out,
> errors => \@errors}) ; ...
> }
> my @correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
> %Embperl::Syntax::MsgIdExtract::Ids;
>
> but I think it's a bug
>
>
> - MsgIdExtract ignores [- $epreq->gettext(expr) -] I don't
> know how to modify the syntax, but it's clearly a bug
>
>
> - when messages are dumped with $Data::Dumper::Useqq = 1 it
> break 8bit chars (dump as octal, but translators would go mad
> should they see it)
>
>
> - I find it more practical to dump sorted messages with
> something like $Data::Dumper::Sortkeys = \&{ sub {[ sort {
> $a cmp $b } keys %{$_[0]} ]} }
>
>
> - app file must delete empty (missing) translations to force
> EP use message in the default language, this is quite
> impractical because translators need it in the dictionary
> file and so during the development I need to modify the
> dictionary either for EP or for translators. Now I delete it
> in app file but it's stupid performance-wise
>
> - Robert
>
> -------------------------------------
>
> Just in case somebody needs it, below are necessary files
>
> _app.eo
>
> -------------------------------------
>
> @ISA = ('Embperl::App') ;
>
> sub init {
> my $self = shift ;
> my $r = $self->curr_req ;
> my $fdat = $r->thread->form_hash;
> my $lang = $fdat->{lang} || 'en' ;
> my %messages = %{ do '/home/www/germic/etc/dict/dict.dump' };
>
> foreach my $l (keys %messages) {
> foreach my $t (keys %{ $messages{$l} }) {
> delete $messages{$l}{$t} unless $messages{$l}{$t};
> }
> }
>
> #use Data::Dumper; print STDERR "\n\n", Dumper(\%messages), "\n\n";
>
> push @{$r->messages}, $messages{$lang} ;
> push @{$r->default_messages}, $messages{'en'} if
> ($lang ne 'en') ;
>
> return 0;
>
> }
>
> 1 ;
>
> -------------------------------------
>
> extract
>
> -------------------------------------
>
> BEGIN
> {
> %Embperl::initparam = (use_env => 1, use_redirect_env => 1) ;
> $ENV{EMBPERL_SESSION_HANDLER_CLASS} = 'no' ;
> }
>
> use Embperl;
> use Data::Dumper ;
>
> use strict;
> use vars qw{$srcpath $dictpath @files @languages $msgids
> @correct_keys};
>
> $srcpath = '/home/www/germic';
> $dictpath = '/home/www/germic/etc/dict';
> @files = split ' ', `find $srcpath -name *.html
> -printf "%p " -or -name *.eo -printf "%p "`;
> @languages = qw(cz de); # en not listed, it's default!
>
> $msgids = do "$dictpath/dict.dump" ;
> die $@ if ($@) ;
> #print Dumper($msgids);
>
> foreach my $fn (@files) {
> my ( $out, @errors );
> Embperl::Execute ({use_env => 1, use_redirect_env => 1,
> syntax => 'MsgIdExtract', inputfile => $fn, output => \$out,
> errors => \@errors}) ;
> if (@errors) {
> print join ("\n", @errors) ;
> last ;
> }
> }
> #print Dumper(\%Embperl::Syntax::MsgIdExtract::Ids);
>
> @correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
> %Embperl::Syntax::MsgIdExtract::Ids;
> #print Dumper(\@correct_keys);
>
> foreach my $lang (@languages) {
> foreach my $k (@correct_keys) {
> $msgids -> {en}{$k} = $k ;
> $msgids -> {$lang}{$k} = '' if (!exists $msgids ->
> {$lang}{$k}) ;
> }
> }
> #print Dumper($msgids);
>
> rename "$dictpath/dict.dump", "$dictpath/dict.bak" ; open FH,
> ">$dictpath/dict.dump" or die "Cannot open
> $dictpath/dict.dump ($!)" ; # $Data::Dumper::Indent = 1 ; #
> default is nicer # $Data::Dumper::Useqq = 1 ; # breaks 8bit
> chars $Data::Dumper::Sortkeys = \&{ sub {[ sort { $a cmp $b
> } keys %{$_[0]} ]} } ; # more practical print FH
> Data::Dumper -> Dump ([$msgids], ['msgids']) ; close FH ;
>
> -------------------------------------
>
> test
>
> -------------------------------------
>
> <h1>trans test</h1>
>
> <p>Test: <b>[= Test =]</b>
> <p>Hi!: <b>[= Hi! =]</b>
> <p>Thank You!: <b>[= Thank You! =]</b>
> <p>Athos, Porthos, Aramis & d'Artagnan: <b>[= Athos,
> Porthos, Aramis & d'Artagnan =]</b> <p>How's life?: <b>[+
> $epreq->gettext(qq{How's life?}) +]<b>
>
>
>
>
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Multilingual support / was Re: Urgent: MsgIdExtract problem
Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:
>>'$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
>>($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>>
>>
>
>Try to change %#0% to %#\'0%
>
>
OK, now I got it working and it's really cool (with the exception of the
last couple of bugs). Here are my comments (relevant for 2.0RC2):
- I changed MsgIdExtract syntax from %#0% to %#\'0%, now it correctly
extracts more complex expressions, but it adds superflous quotes and a
space to the extracted expressions, it looks like this '\'Test \'' =>
'', This can be hacked in the extract script with something like
foreach my $fn (@files) {
...
Embperl::Execute ({use_env => 1, use_redirect_env => 1, syntax =>
'MsgIdExtract', inputfile => $fn, output => \$out, errors => \@errors}) ;
...
}
my @correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
%Embperl::Syntax::MsgIdExtract::Ids;
but I think it's a bug
- MsgIdExtract ignores [- $epreq->gettext(expr) -] I don't know how to
modify the syntax, but it's clearly a bug
- when messages are dumped with $Data::Dumper::Useqq = 1 it break 8bit
chars (dump as octal, but translators would go mad should they see it)
- I find it more practical to dump sorted messages with something like
$Data::Dumper::Sortkeys = \&{ sub {[ sort { $a cmp $b } keys %{$_[0]} ]} }
- app file must delete empty (missing) translations to force EP use
message in the default language, this is quite impractical because
translators need it in the dictionary file and so during the development
I need to modify the dictionary either for EP or for translators. Now I
delete it in app file but it's stupid performance-wise
- Robert
-------------------------------------
Just in case somebody needs it, below are necessary files
_app.eo
-------------------------------------
@ISA = ('Embperl::App') ;
sub init {
my $self = shift ;
my $r = $self->curr_req ;
my $fdat = $r->thread->form_hash;
my $lang = $fdat->{lang} || 'en' ;
my %messages = %{ do '/home/www/germic/etc/dict/dict.dump' };
foreach my $l (keys %messages) {
foreach my $t (keys %{ $messages{$l} }) {
delete $messages{$l}{$t} unless $messages{$l}{$t};
}
}
#use Data::Dumper; print STDERR "\n\n", Dumper(\%messages), "\n\n";
push @{$r->messages}, $messages{$lang} ;
push @{$r->default_messages}, $messages{'en'} if ($lang ne 'en') ;
return 0;
}
1 ;
-------------------------------------
extract
-------------------------------------
BEGIN
{
%Embperl::initparam = (use_env => 1, use_redirect_env => 1) ;
$ENV{EMBPERL_SESSION_HANDLER_CLASS} = 'no' ;
}
use Embperl;
use Data::Dumper ;
use strict;
use vars qw{$srcpath $dictpath @files @languages $msgids @correct_keys};
$srcpath = '/home/www/germic';
$dictpath = '/home/www/germic/etc/dict';
@files = split ' ', `find $srcpath -name *.html -printf "%p " -or
-name *.eo -printf "%p "`;
@languages = qw(cz de); # en not listed, it's default!
$msgids = do "$dictpath/dict.dump" ;
die $@ if ($@) ;
#print Dumper($msgids);
foreach my $fn (@files) {
my ( $out, @errors );
Embperl::Execute ({use_env => 1, use_redirect_env => 1, syntax =>
'MsgIdExtract', inputfile => $fn, output => \$out, errors => \@errors}) ;
if (@errors) {
print join ("\n", @errors) ;
last ;
}
}
#print Dumper(\%Embperl::Syntax::MsgIdExtract::Ids);
@correct_keys = map { /^\'\s*(.*?)\s*\'$/ } keys
%Embperl::Syntax::MsgIdExtract::Ids;
#print Dumper(\@correct_keys);
foreach my $lang (@languages) {
foreach my $k (@correct_keys) {
$msgids -> {en}{$k} = $k ;
$msgids -> {$lang}{$k} = '' if (!exists $msgids -> {$lang}{$k}) ;
}
}
#print Dumper($msgids);
rename "$dictpath/dict.dump", "$dictpath/dict.bak" ;
open FH, ">$dictpath/dict.dump" or die "Cannot open $dictpath/dict.dump
($!)" ;
# $Data::Dumper::Indent = 1 ; # default is nicer
# $Data::Dumper::Useqq = 1 ; # breaks 8bit chars
$Data::Dumper::Sortkeys = \&{ sub {[ sort { $a cmp $b } keys %{$_[0]}
]} } ; # more practical
print FH Data::Dumper -> Dump ([$msgids], ['msgids']) ;
close FH ;
-------------------------------------
test
-------------------------------------
<h1>trans test</h1>
<p>Test: <b>[= Test =]</b>
<p>Hi!: <b>[= Hi! =]</b>
<p>Thank You!: <b>[= Thank You! =]</b>
<p>Athos, Porthos, Aramis & d'Artagnan: <b>[= Athos, Porthos, Aramis &
d'Artagnan =]</b>
<p>How's life?: <b>[+ $epreq->gettext(qq{How's life?}) +]<b>
RE: Urgent: MsgIdExtract problem
Posted by Gerald Richter <ri...@ecos.de>.
Did you change the syntax as I proposed:
> '$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
> ($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
Try to change
%#0%
to
%#\'0%
?? (Note the additional \' )
Gerald
---------------------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
> -----Original Message-----
> From: RobertCZ [mailto:robert@robert.cz]
> Sent: Tuesday, December 14, 2004 1:23 PM
> To: embperl@perl.apache.org
> Cc: Gerald Richter
> Subject: Re: Urgent: MsgIdExtract problem
>
> Now it does the extracting right (with a lot of quotes ;-)),
> but it does not seem to show the actual translations in the
> page itself
>
> - Robert
>
>
>
> Gerald Richter wrote:
>
> when extracting messages. I believe in some
> older version
> quotes like [= 'Hello World' =] would fix it,
> but in RC2 it
> just prints it with quotes 'Hello World'.
>
> The problem is perhaps this definition
>
> 'Embperl output msg id' => {
> 'text' => '[=',
> 'end' => '=]',
> 'unescape' => 1,
> 'procinfo' => {
> embperl => {
> perlcode =>
> [
>
>
> '$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
> ($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>
>
>
> Try to change
>
> %#0%
>
> to
>
> %#\'0%
>
> Does this help?
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Urgent: MsgIdExtract problem
Posted by RobertCZ <ro...@robert.cz>.
Now it does the extracting right (with a lot of quotes ;-)), but it does
not seem to show the actual translations in the page itself
- Robert
Gerald Richter wrote:
>> when extracting messages. I believe in some older version
>>quotes like [= 'Hello World' =] would fix it, but in RC2 it
>>just prints it with quotes 'Hello World'.
>>
>>The problem is perhaps this definition
>>
>> 'Embperl output msg id' => {
>> 'text' => '[=',
>> 'end' => '=]',
>> 'unescape' => 1,
>> 'procinfo' => {
>> embperl => {
>> perlcode =>
>> [
>>
>>'$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
>>($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>>
>>
>
>Try to change
>
>%#0%
>
> to
>
>%#\'0%
>
>Does this help?
>
>
Re: Urgent: MsgIdExtract problem
Posted by Robert Germic <ge...@pcv.cz>.
Gerald Richter wrote:
>>- [= Clear Form! =] doesn't show translation even when
>>dictionary has ... 'cz' => { ..., 'Clear Form!' => 'Vymazat
>>formular!', ... }, it looks like the above bug is repeated
>>when Emperl ouputs text
>>
>>
>>
>
>That's the same bug.
>
>
You are not saying that quote fix you proposed would solve this one, too
- are you? Going to try it right now...
>>- your syntax ignores (documented) usage $epreq->gettext()
>>
>>
>
>I don't understand this?
>
>
>
How do you extract strings from expressions like [- $epreq->('Clear
Form!') -] with your [= =] based Syntax file?
--
S pozdravem/Best Regards
Robert Germic
Prvni ceska virtualni s.r.o., Vinohradska 25/35, CZ-120 00 Praha 2
Email: germic@pcv.cz, Mob. tel.: (+420 602) 213 480
NetBooking Czech Republic s.r.o., Trebohostická 12, CZ-100 00 Praha 10
Email: germic@netbooking.cz, Mob. tel.: (+420 602) 512 512
RE: Urgent: MsgIdExtract problem
Posted by Gerald Richter <ri...@ecos.de>.
>
> - [= Clear Form! =] doesn't show translation even when
> dictionary has ... 'cz' => { ..., 'Clear Form!' => 'Vymazat
> formular!', ... }, it looks like the above bug is repeated
> when Emperl ouputs text
>
That's the same bug.
> - your syntax ignores (documented) usage $epreq->gettext()
>
I don't understand this?
Gerald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Urgent: MsgIdExtract problem
Posted by RobertCZ <ro...@robert.cz>.
Gerald Richter wrote:
>> when extracting messages. I believe in some older version
>>quotes like [= 'Hello World' =] would fix it, but in RC2 it
>>just prints it with quotes 'Hello World'.
>>
>>The problem is perhaps this definition
>>
>> 'Embperl output msg id' => {
>> 'text' => '[=',
>> 'end' => '=]',
>> 'unescape' => 1,
>> 'procinfo' => {
>> embperl => {
>> perlcode =>
>> [
>>
>>'$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
>>($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
>>
>>
>
>Try to change
>
>%#0%
>
> to
>
>%#\'0%
>
>Does this help?
>
>
I'm going to test it. Meanwhile I'm using simple hack with regexps and
noticed more problems:
- [= Clear Form! =] doesn't show translation even when dictionary has
... 'cz' => { ..., 'Clear Form!' => 'Vymazat formular!', ... }, it looks
like the above bug is repeated when Emperl ouputs text
- your syntax ignores (documented) usage $epreq->gettext()
- Robert
RE: Urgent: MsgIdExtract problem
Posted by Gerald Richter <ri...@ecos.de>.
>
> when extracting messages. I believe in some older version
> quotes like [= 'Hello World' =] would fix it, but in RC2 it
> just prints it with quotes 'Hello World'.
>
> The problem is perhaps this definition
>
> 'Embperl output msg id' => {
> 'text' => '[=',
> 'end' => '=]',
> 'unescape' => 1,
> 'procinfo' => {
> embperl => {
> perlcode =>
> [
>
> '$Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)} = q{} if (!exists
> ($Embperl::Syntax::MsgIdExtract::Ids{scalar(%#0%)})) ;',
Try to change
%#0%
to
%#\'0%
Does this help?
Gerald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org