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?


In reply to Mason component with utf8 text by ph0enix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.