1Template::Multilingual(U3s)er Contributed Perl DocumentatTieomnplate::Multilingual(3)
2
3
4

NAME

6       Template::Multilingual - Multilingual templates for Template Toolkit
7

SYNOPSIS

9       This subclass of Template Toolkit's "Template" class supports
10       multilingual templates: templates that contain text in several
11       languages.
12
13           <t>
14             <en>Hello!</en>
15             <fr>Bonjour !</fr>
16           </t>
17
18       Specify the language to use when processing a template:
19
20           use Template::Multilingual;
21
22           my $template = Template::Multilingual->new();
23           $template->language('en');
24           $template->process('example.ttml');
25
26       You can also provide the name of the template variable that will hold
27       the language:
28
29           my $template = Template::Multilingual->new(LANGUAGE_VAR => 'foo');
30           $template->process('example.ttml', { foo => 'en' });
31

METHODS

33   new(\%params)
34       The new() constructor creates and returns a reference to a new template
35       object. A reference to a hash may be supplied as a parameter to provide
36       configuration values.
37
38       Configuration values are all valid "Template" superclass options, and
39       one specific to this class:
40
41       LANGUAGE_VAR
42           The LANGUAGE_VAR option can be used to set the name of the template
43           variable which contains the current language.
44
45             my $parser = Template::Multilingual->new({
46                LANGUAGE_VAR => 'global.language',
47             });
48
49           If this option is set, your code is responsible for setting the
50           variable's value to the current language when processing the
51           template. Calling "language()" will have no effect.
52
53           If this option is not set, it defaults to language.
54
55   language($lcode)
56       Specify the language to be used when processing the template. Any
57       string that matches "\w+" is fine, but we suggest sticking to ISO-639
58       which provides 2-letter codes for common languages and 3-letter codes
59       for many others.
60
61   process
62       Used exactly as the original Template Toolkit "process" method.  Be
63       sure to call "language" before calling "process".
64

LANGUAGE SUBTAG HANDLING

66       This module supports language subtags to express variants, e.g. "en_US"
67       or "en-US".  Here are the rules used for language matching:
68
69       ·   Exact match: the current language is found in the template
70
71             language    template                              output
72             fr          <fr>foo</fr><fr_CA>bar</fr_CA>        foo
73             fr_CA       <fr>foo</fr><fr_CA>bar</fr_CA>        bar
74
75       ·   Fallback to the primary language
76
77             language    template                              output
78             fr_CA       <fr>foo</fr><fr_BE>bar</fr_BE>        foo
79
80       ·   Fallback to first (in alphabetical order) other variant of the
81           primary language
82
83             language    template                              output
84             fr          <fr_FR>foo</fr_FR><fr_BE>bar</fr_BE>  bar
85             fr_CA       <fr_FR>foo</fr_FR><fr_BE>bar</fr_BE>  bar
86

AUTHOR

88       Eric Cholet, "<cholet@logilune.com>"
89

BUGS

91       Multilingual text sections cannot be used inside TT directives.  The
92       following is illegal and will trigger a TT syntax error:
93
94           [% title = "<t><fr>Bonjour</fr><en>Hello</en></t>" %]
95
96       Use this instead:
97
98           [% title = BLOCK %]<t><fr>Bonjour</fr><en>Hello</en></t>[% END %]
99
100       The TAG_STYLE, START_TAG and END_TAG directives are supported, but the
101       TAGS directive is not.
102
103       Please report any bugs or feature requests to
104       "bug-template-multilingual@rt.cpan.org", or through the web interface
105       at
106       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-Multilingual>.
107       I will be notified, and then you'll automatically be notified of
108       progress on your bug as I make changes.
109

SEE ALSO

111       If you are already using your own "Template" subclass, you may find it
112       easier to use Template::Multilingual::Parser instead.
113
114       ISO 639-2 Codes for the Representation of Names of Languages:
115       http://www.loc.gov/standards/iso639-2/langcodes.html
116
118       Copyright 2009 Eric Cholet, All Rights Reserved.
119
120       This program is free software; you can redistribute it and/or modify it
121       under the same terms as Perl itself.
122
123
124
125perl v5.28.0                      2018-11-08         Template::Multilingual(3)
Impressum