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: [EMAIL PROTECTED] 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:[EMAIL PROTECTED] > 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 => [EMAIL PROTECTED]) ; ... > } > 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 => [EMAIL PROTECTED]) ; > 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([EMAIL PROTECTED]); > > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]