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?