Mojolicious::Plugin::I18N - Internationalization Plugin for Mojolicious
# Mojolicious
$self->plugin('I18N');
% languages 'de';
%=l 'hello'
# Mojolicious::Lite (detect language from URL, i.e. /en/ or /de/)
plugin I18N => {namespace => 'MyApp::I18N', support_url_langs => [qw(en de)]};
%=l 'hello'
# Lexicon
package MyApp::I18N::de;
use Mojo::Base 'MyApp::I18N';
our %Lexicon = (hello => 'hallo');
1;
Mojolicious::Plugin::I18N is internationalization plugin for Mojolicious It works with Mojolicious 4.0+.
Old namespace is Mojolicious::Plugin::I18N2.
Mojolicious::Plugin::I18N supports the following options.
plugin I18N => {support_url_langs => [qw(en de)]};
Detect language from URL.
plugin I18N => {support_hosts => { 'mojolicious.ru' => 'ru', 'mojolicio.us' => 'en' }};
Detect Host header and use language for that host.
plugin I18N => {no_header_detect => 1};
Off header detect.
plugin I18N => {default => 'en'};
Default language for i18n, defaults to en
.
plugin I18N => {namespace => 'MyApp::I18N'};
Lexicon namespace, defaults to the application class followed by ::I18N
.
Mojolicious::Plugin::I18N implements helpers same as Mojolicious::Plugin::I18N.
%=l 'hello'
$self->l('hello');
Translate sentence.
% languages 'de';
$self->languages('de');
Change languages.
Mojolicious::Plugin::I18N inherits all methods from Mojolicious::Plugin::I18N and reimplements the following new ones.
$plugin->register;
Register plugin hooks and helpers in Mojolicious application.
Mojolicious::Plugin::I18N has debug mode.
# debug mode on
BEGIN { $ENV{MOJO_I18N_DEBUG} = 1 };
# or
MOJO_I18N_DEBUG=1 perl script.pl
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
2011-2014 Anatoly Sharifulin <[email protected]>
2010-2012 Sebastian Riedel <[email protected]>
Please report any bugs or feature requests to bug-mojolicious-plugin-i18n at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.htMail?Queue=Mojolicious-Plugin-I18N. We will be notified, and then you'll automatically be notified of progress on your bug as we make changes.
Github
http://github.com/sharifulin/mojolicious-plugin-i18n/tree/master
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.htMail?Dist=Mojolicious-Plugin-I18N
AnnoCPAN: Annotated CPAN documentation
CPANTS: CPAN Testing Service
http://cpants.perl.org/dist/overview/Mojolicious-Plugin-I18N
CPAN Ratings
Search CPAN
Copyright (C) 2011-2014 by Anatoly Sharifulin. Copyright (C) 2008-2012, Sebastian Riedel.
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.