Mojolicious::Plugin::Message::Locale - Mojolicious Plugin
# locale.conf { common => { title => { en => 'TITLE', ja => 'タイトル' }, message => { en => 'MESSAGE', ja => 'メッセージ' } }, original => { message => { en => 'OROGINAL MESSAGE', ja => 'オリジナル' } } } # Mojolicious $self->plugin('Message::Locale', { default_message => '', locale => 'en', file => 'locale.conf', }); # same $self->plugin('Message::Locale'); $self->locale('message', 'common'); # MESSAGE $self->locale('message', 'original'); # ORIGINAL MESSAGE $self->set_locale('ja'); $self->locale('title'); # タイトル $self->locale('message', 'original'); # オリジナル $self->set_locale('en'); $self->locale('title'); # TITLE $self->locale('title', 'original'); # TITLE # template .html.ep <%= locale "title" %> <%= locale "title", "original" %> <%= locale "message" %> <%= locale "message", "original" %>
Mojolicious::Plugin::Message::Locale is a plugin for Mojolicious apps to localize messages using Mojolicious::Plugin::Config
Mojolicious::Plugin::Message::Locale inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register($app, $conf);
Register plugin in Mojolicious application.
Mojolicious, Mojolicious::Guides, http://mojolicious.
Kei Shimada <sasakure_kei __at__ cpan.org>
<sasakure_kei __at__ cpan.org>
git clone git@github.com:sasakure-kei/p5-Mojolicious-Plugin-Message-Locale.git
Copyright (c) 2012, Kei Shimada <sasakure_kei __at__ cpan.org>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Mojolicious::Plugin::Message::Locale, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::Message::Locale
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::Message::Locale
For more information on module installation, please visit the detailed CPAN module installation guide.