Skip to content

Commit

Permalink
added internationalization recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 23, 2012
1 parent 39ac334 commit 71f299a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.67 2012-03-24
- Improved documentation.
- Improved tests.

2.66 2012-03-23
Expand Down
30 changes: 30 additions & 0 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -712,6 +712,36 @@ templates.

Less commonly used and more powerful features.

=head2 Internationalization

Thanks to L<Locale::Maketext>, all you need for basic internationalization
support in your application is the plugin L<Mojolicious::Plugin::I18N> and a
few lexicon classes.

package MyApp::I18N::de;
use base 'MyApp::I18N';

our %Lexicon = ('Hello World' => 'Hallo Welt');

package main;
use Mojolicious::Lite;

plugin I18N => {namespace => 'MyApp::I18N'};

get '/' => 'hello';

app->start;
__DATA__

@@ hello.html.ep
<%=l 'Hello World' %>!

Preferred languages will be automatically detected from the
C<Accept-Language> header or can be manually changed with the helper
L<Mojolicious::Plugin::I18N/"languages">.

$ ./myapp.pl get / -H 'Accept-Language: de'

=head2 Chunked transfer encoding

For very dynamic content you might not know the response C<Content-Length>
Expand Down

0 comments on commit 71f299a

Please sign in to comment.