1Catalyst::Plugin::I18N(U3s)er Contributed Perl DocumentatCiaotnalyst::Plugin::I18N(3)
2
3
4
6 Catalyst::Plugin::I18N - I18N for Catalyst
7
9 use Catalyst 'I18N';
10
11 print join ' ', @{ $c->languages };
12 $c->languages( ['de'] );
13 print $c->localize('Hello Catalyst');
14
15 Use a macro if you're lazy:
16
17 [% MACRO l(text, args) BLOCK;
18 c.localize(text, args);
19 END; %]
20
21 [% l('Hello Catalyst') %]
22 [% l('Hello [_1]', 'Catalyst') %]
23 [% l('lalala[_1]lalala[_2]', ['test', 'foo']) %]
24 [% l('messages.hello.catalyst') %]
25
27 Supports mo/po files and Maketext classes under your application's I18N
28 namespace.
29
30 # MyApp/I18N/de.po
31 msgid "Hello Catalyst"
32 msgstr "Hallo Katalysator"
33
34 # MyApp/I18N/i_default.po
35 msgid "messages.hello.catalyst"
36 msgstr "Hello Catalyst - fallback translation"
37
38 # MyApp/I18N/de.pm
39 package MyApp::I18N::de;
40 use base 'MyApp::I18N';
41 our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
42 1;
43
44 CONFIGURATION
45 You can override any parameter sent to Locale::Maketext::Simple by
46 specifying a "maketext_options" hashref to the "Plugin::I18N" config
47 section. For example, the following configuration will override the
48 "Decode" parameter which normally defaults to 1:
49
50 __PACKAGE__->config(
51 'Plugin::I18N' =>
52 maketext_options => {
53 Decode => 0
54 }
55 );
56
57 All languages fallback to MyApp::I18N which is mapped onto the
58 i-default language tag. If you use arbitrary message keys, use
59 i_default.po to translate into English, otherwise the message key
60 itself is returned.
61
62 EXTENDED METHODS
63 setup
64
65 METHODS
66 languages
67
68 Contains languages.
69
70 $c->languages(['de_DE']);
71 print join '', @{ $c->languages };
72
73 language
74
75 return selected locale in your locales list.
76
77 language_tag
78
79 return language tag for current locale. The most notable difference
80 from this method in comparison to "language()" is typically that
81 languages and regions are joined with a dash and not an underscore.
82
83 $c->language(); # en_us
84 $c->language_tag(); # en-us
85
86 installed_languages
87
88 Returns a hash of { langtag => "descriptive name for language" } based
89 on language files in your application's I18N directory. The descriptive
90 name is based on I18N::LangTags::List information. If the descriptive
91 name is not available, will be undef.
92
93 loc
94
95 localize
96
97 Localize text.
98
99 print $c->localize( 'Welcome to Catalyst, [_1]', 'sri' );
100
102 Catalyst
103
105 Sebastian Riedel <sri@cpan.org>
106
107 Brian Cassidy <bricas@cpan.org>
108
109 Christian Hansen <chansen@cpan.org>
110
112 Copyright (c) 2005 - 2009 the Catalyst::Plugin::I18N "AUTHORS" as
113 listed above.
114
115 This program is free software, you can redistribute it and/or modify it
116 under the same terms as Perl itself.
117
118
119
120perl v5.34.0 2022-01-21 Catalyst::Plugin::I18N(3)