Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Mason component with utf8 text

by ph0enix (Friar)
on May 27, 2004 at 09:35 UTC ( [id://356848]=perlquestion: print w/replies, xml ) Need Help??

ph0enix has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I want to use HTML::Mason for some site which should be localized to various languages. I tryied to use i18n component mentioned in documentation, but texts are not marked as utf8. Currently my modified component code call Encode::decode_utf8(). And yes, I can do replace s/decode_utf8/_utf8_on/ to only set utf8 flag.

<% $text %> <%once> use Encode qw//; </%once> <%init> # Get language information from session my $lang = $m->session->{'use_site_lang'}; my $text; ($text) = $m->content =~ m{<$lang>(.+?)</$lang>}s; if (!defined $text) { # no translation - fallback to english $lang = 'en'; ($text) = $m->content =~ m{<en>(.+?)</en>}s; } # decode back to utf8 $text = Encode::decode_utf8($text); </%init>

Component is than called

<&| /lib/i18n &> <en>English text.</en> <cs>Czech text.</cs> # ... another language can be added </&>

Is there another way to use utf8 texts in in Mason components?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://356848]
Approved by kvale
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found