Created
December 13, 2010 09:15
-
-
Save shoorick/738816 to your computer and use it in GitHub Desktop.
Mojolicious::Lite with Mojolicious::Plugin::Textdomain example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojolicious::Lite; | |
get '/' => sub { | |
my $self = shift; | |
$self->render( | |
'template' => 'index', | |
'count' => int rand 33, | |
); | |
}; | |
plugin 'charset' => { 'charset' => 'utf8' }; | |
plugin 'textdomain' => { | |
'domain' => 'example', | |
'search_dirs' => [ 'locale' ], | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
% layout 'page'; | |
in template: | |
%= __ 'It works?'; | |
<p>Plural via <code>__nx</code>: | |
<%= __nx '{count} apple was found', '{count} apples were found', $count, 'count' => $count %> | |
</p> | |
<p>Plural via <code>__n</code>: | |
<%= sprintf __n ( '%d apple was found', '%d apples were found', $count), $count %> | |
</p> | |
@@ layouts/page.html.ep | |
<!doctype html><html> | |
<head><title>i18n <%= __ 'Example' %></title></head> | |
<body> | |
<h1>in layout: <%= __ 'It works?' %></h1> | |
<%== content %> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment