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