Scroll to navigation

Mojolicious::Plugin::I18N(3pm) User Contributed Perl Documentation Mojolicious::Plugin::I18N(3pm)
 

NAME

Mojolicious::Plugin::I18N - Internationalization Plugin for Mojolicious

SYNOPSIS

  # 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;

DESCRIPTION

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 on
  BEGIN { $ENV{MOJO_I18N_DEBUG} = 1 };
  # or
  MOJO_I18N_DEBUG=1 perl script.pl

SEE ALSO

Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.

AUTHORS

2011-2014 Anatoly Sharifulin <sharifulin@gmail.com>
2010-2012 Sebastian Riedel <kraihx@googlemail.com>

BUGS

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
<http://annocpan.org/dist/Mojolicious-Plugin-I18N>
CPANTS: CPAN Testing Service
<http://cpants.perl.org/dist/overview/Mojolicious-Plugin-I18N>
CPAN Ratings
<http://cpanratings.perl.org/d/Mojolicious-Plugin-I18N>
Search CPAN
<http://search.cpan.org/dist/Mojolicious-Plugin-I18N>

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.
2014-10-12 perl v5.20.1