Dancer2::Plugin::Multilang - Dancer2 Plugin to create multilanguage sites
A plugin for Dancer2 to create multilanguage sites. In your app you can configure any route you want as /myroute/to/page.
Plugin will make the app answer to /en/myroute/to/page or /it/myroute/to/page giving the language path to the route manager as a Dancer keyword. It will also redirect navigation using information from the headers transmitted from the browser. Language change during navigation will be managed via cookie.
Multilanguage SEO headers will be generated to give advice to the search engines about the language of the pages.
# In your Dancer2 app, use Dancer2::Plugin::Multilang #In your config.yml plugins: Multilang: languages: ['it', 'en'] default: 'it' where languages is the array of all the languages managed and default is the response language if no information about language can be retrieved. #In the routes get '/route/to/page' => sub { if( language == 'en' ) { /* english navigation */ } elsif( language == 'it' ) { /* italian navigation */ } elsif...
No language information has to be managed in route definition. Language path will be added transparently to your routes.
language keyword can be used to retrieve language information inside the route manager.
The options you can configure are:
languages
The array of the languages that will be managed.
All the languages are two characters codes as in the primary tag defined by http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.10
default
The default language that will be used when plugin can't guess desired one (or when desired one is not managed)
no_lang_prefix
Do not add the language path to the route if it has this prefix. Useful for Google or Facebook authentication callbacks.
no_lang_prefix: /auth
To install Dancer2::Plugin::Multilang, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Plugin::Multilang
CPAN shell
perl -MCPAN -e shell install Dancer2::Plugin::Multilang
For more information on module installation, please visit the detailed CPAN module installation guide.