Mojolicious::Plugin::I18n - Intenationalization Plugin
# Mojolicious $self->plugin('i18n'); % languages 'de'; <%=l 'hello' %> # Mojolicious::Lite plugin 'i18n' => {namespace => 'MyApp::I18N'}; <%=l 'hello' %> # Lexicon package MyApp::I18N::de; use base 'MyApp::I18N'; our %Lexicon = (hello => 'hallo'); 1;
Mojolicous::Plugin::I18n adds Locale::Maketext support to Mojolicious. All you have to do besides using this plugin is to add as many lexicon classes as you need. Languages can usually be detected automatically from the Accept-Languages request header.
Accept-Languages
# Mojolicious::Lite plugin i18n => {default => 'en'};
# Mojolicious::Lite plugin i18n => {namespace => 'MyApp::I18N'};
<%=l 'hello' %>
Translate sentence.
<% languages 'de'; %>
Change languages.
Mojolicious::Plugin::I18n inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register;
Register plugin hooks and helpers in Mojolicious application.
Mojolicious, Mojolicious::Guides, http://mojolicious.org.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.