Cataly...::I18N(3pm)
π Catalyst::Plugin::I18N β the manual, but make it cute π
okay so bestie, this is the manual page for Catalyst::Plugin::I18N β it's the perl one (section 3pm), and it's literally the way you make your Catalyst app speak every language. πβ¨
β¨ NAME β¨
Catalyst::Plugin::I18N β I18N for Catalyst. that's it, that's the name, slay. π
π SYNOPSIS π
the vibe is: plug it in, set your languages, localize your lil strings.
use Catalyst 'I18N';
print join ' ', @{ $c->languages };
$c->languages( ['de'] );
print $c->localize('Hello Catalyst');
and if you're feeling lazy (no judgement, we've all been there π), use a macro:
[% MACRO l(text, args) BLOCK;
c.localize(text, args);
END; %]
[% l('Hello Catalyst') %]
[% l('Hello [_1]', 'Catalyst') %]
[% l('lalala[_1]lalala[_2]', ['test', 'foo']) %]
[% l('messages.hello.catalyst') %]
πΈ DESCRIPTION πΈ
it supports mo/po files and Maketext classes, all living under your application's I18N namespace. it's giving organized. it's giving multilingual queen. π
# MyApp/I18N/de.po
msgid "Hello Catalyst"
msgstr "Hallo Katalysator"
# MyApp/I18N/i_default.po
msgid "messages.hello.catalyst"
msgstr "Hello Catalyst - fallback translation"
# MyApp/I18N/de.pm
package MyApp::I18N::de;
use base 'MyApp::I18N';
our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
1;
βοΈ CONFIGURATION βοΈ
you can override any parameter that gets sent to Locale::Maketext::Simple by handing a maketext_options hashref to the Plugin::I18N config section. like, literally any of them. main character energy fr fr.
for example, this config right here overrides the Decode parameter, which normally defaults to 1:
__PACKAGE__->config(
'Plugin::I18N' =>
maketext_options => {
Decode => 0
}
);
every language falls back to MyApp::I18N, which is mapped onto the i-default language tag. and if you're using arbitrary message keys, use i_default.po to translate them into English β otherwise the message key itself is what gets returned. iykyk. π
π₯ EXTENDED METHODS π₯
setup
π METHODS π
languages
contains languages. yeah, it just holds them. iconic behaviour honestly.
$c->languages(['de_DE']);
print join '', @{ $c->languages };
language
returns the selected locale from your locales list.
language_tag
returns the language tag for the current locale. the most notable difference between this method and language() is typically that languages and regions are joined with a dash and not an underscore. π¦
$c->language(); # en_us
$c->language_tag(); # en-us
installed_languages
returns a hash shaped like { langtag => "descriptive name for language" }, based on the language files chillin' in your application's I18N directory. the descriptive name comes from I18N::LangTags::List info. and if that descriptive name isn't available? it'll be undef. π
loclocalize
localizes text. the moment we've all been waiting for.
print $c->localize( 'Welcome to Catalyst, [_1]', 'sri' );
π SEE ALSO π
Catalyst
π«Ά AUTHORS π«Ά
- Sebastian Riedel <sri@cpan.org>
- Brian Cassidy <bricas@cpan.org>
- Christian Hansen <chansen@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (c) 2005 - 2009 the Catalyst::Plugin::I18N "AUTHORS" as listed above.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
and that's a wrap bestie!! this page came straight out ofperlversionv5.36.0, dated2022-11-27. go forth and translate everything, you absolute legend πβ¨π
π¦ where this page comes from
- debian bookworm: libcatalyst-plugin-i18n-perl 0.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcatalyst-plugin-i18n-perl 0.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatalyst-plugin-i18n-perl 0.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatalyst-plugin-i18n-perl 0.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatalyst-plugin-i18n-perl 0.10-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms