Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 chanting in the Monastery: (3)
As of 2024-06-15 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.