Mojolicious::Plugin::I18N3pm
Internationalization plugin for mojolicious
Usage
# 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'# Lexiconpackage MyApp::I18N::de;use Mojo::Base 'MyApp::I18N';our %Lexicon = (hello => 'hallo');1;
Overview
Mojolicious::Plugin::I18N is internationalization plugin for Mojolicious It works with Mojolicious 4.0+.
Old namespace is Mojolicious::Plugin::I18N2.
Options
Mojolicious::Plugin::I18N supports the following options.
"support_url_langs"
plugin I18N => {support_url_langs => [qw(en de)]};
Detect language from URL.
"support_hosts"
plugin I18N => {support_hosts => { 'mojolicious.ru' => 'ru', 'mojolicio.us' => 'en' }};
Detect Host header and use language for that host.
"no_header_detect"
plugin I18N => {no_header_detect => 1};
Off header detect.
"default"
plugin I18N => {default => 'en'};
Default language for i18n, defaults to "en".
"namespace"
plugin I18N => {namespace => 'MyApp::I18N'};
Lexicon namespace, defaults to the application class followed by "::I18N".
Helpers
Mojolicious::Plugin::I18N implements helpers same as Mojolicious::Plugin::I18N.
"l"
%=l 'hello'$self->l('hello');
Translate sentence.
"languages"
% languages 'de';$self->languages('de');
Change languages.
Methods
Mojolicious::Plugin::I18N inherits all methods from Mojolicious::Plugin::I18N and reimplements the following new ones.
"register"
$plugin->register;
Register plugin hooks and helpers in Mojolicious application.
Debug mode
Mojolicious::Plugin::I18N has debug mode.
# debug mode onBEGIN { $ENV{MOJO_I18N_DEBUG} = 1 };# orMOJO_I18N_DEBUG=1 perl script.pl
Copyright & license
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.
Releases
7 releases since Debian 7 (Wheezy); the text changed 3 times.