/usr/share/doc/libtext-xslate-perl/examples/i18n-data-localize.pl is in libtext-xslate-perl 3.5.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Text::Xslate;
use Text::Xslate::Util qw(html_escape html_builder);
use Data::Localize;
use Data::Localize::Gettext;
use FindBin qw($Bin);
use Encode ();
my $i18n = Data::Localize->new(
auto => 1,
languages => ['ja'],
);
$i18n->add_localizer(
class => 'Gettext',
path => "$Bin/locale/*.po",
);
my $xslate = Text::Xslate->new(
syntax => 'TTerse',
function => {
l => sub {
return $i18n->localize(@_);
},
l_raw => html_builder {
my $format = shift;
my @args = map { html_escape($_) } @_;
return $i18n->localize($format, @args);
},
},
);
my %param = (location => '<Tokyo>'); # user inputs
my $body = $xslate->render_string(<<'TEMPLATE', \%param);
[% l_raw('Hello!<br />') %]
[% l_raw('I am in %1<br />', $location) %]
TEMPLATE
print Encode::encode_utf8($body);
|