Skip to content

Instantly share code, notes, and snippets.

@shoorick
Created December 13, 2010 09:15

Revisions

  1. shoorick created this gist Dec 13, 2010.
    40 changes: 40 additions & 0 deletions 2_td.pl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #!/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>