++ed by:
1 non-PAUSE user
Author image Diego Kuperman
and 1 contributors


Catalyst::TraitFor::Controller::LocaleSelect - Provides locale selection mechanism for controllers


Version 0.03


This will run before your auto action, so the locale info is available even if you need it on your auto action.


On your app class

    use Catalyst qw/
        I18N        # or Data::Localize

        LocaleSelect => {
            allowed => [ qw/ en es / ],
            default => 'en'

In your controller ( Apply to root controller to be application wide )

    package MyApp::Controller::Root;
    use Moose;
    use namespace::autoclean;

    BEGIN { extends 'Catalyst::Controller' }
    with 'Catalyst::TraitFor::Controller::LocaleSelect';
    # ...


This controller role will provide locale selection capabilities to your controllers. You can apply it to the root controller to have it working application wide.

Once in use, the controller have auto locale selection among your configured allowed locales. When no one reported by the user agent are allowed, the default will be in use.

This role will give to all actions on the controller two more capabilities:

  • One time locale selection if exists param('locale') and have an allowed value.

  • * Cookie based locale lock-in selection using param('set_locale').

It will also populate the locale key on the stash for later extra use:

    $c->stash( locale => {
        allowed  => [ 'en', 'es' ],
        default  => 'en',
        selected => 'es'             # the one selected for the request


  1. If locale parameter exists, this will be selected.

  2. If set_locale parameter exists, it will be used an cookie stored for later use.

  3. If cookie exists...

  4. If any of the browser supported locales exists...

  5. The default one.


Diego Kuperman, <diego at freekeylabs.com>


Please report any bugs or feature requests to bug-catalyst-traitfor-controller-localeselect at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-TraitFor-Controller-LocaleSelect. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Catalyst::TraitFor::Controller::LocaleSelect

You can also look for information at:


Copyright 2010 Diego Kuperman.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.