Parley::App::I18N - i18n helper functions


Parley documentation Contained in the Parley distribution.

Index


Code Index:

NAME

Top

Parley::App::I18N - i18n helper functions

SYNOPSIS

Top

  use Parley::App::I18N qw( :locale );

  first_valid_locale($c, [qw/path parts/]);

SEE ALSO

Top

Parley::Controller::Root, Catalyst

AUTHOR

Top

Chisel Wright <chiselwright@users.berlios.de>

LICENSE

Top

This library is free software, you can redistribute it and/or modify it under the same terms as Perl itself.


Parley documentation Contained in the Parley distribution.

package Parley::App::I18N;
# vim: ts=8 sts=4 et sw=4 sr sta
use strict;
use warnings;

use Parley::Version;  our $VERSION = $Parley::VERSION;

use Perl6::Export::Attrs;

sub first_valid_locale :Export( :locale ) {
    my ($c, $path_parts) = @_;

    $c->log->debug(
          'first_valid_locale language list: '
        . "@{$c->languages}"
    )
    if $ENV{CATALYST_DEBUG};

    foreach my $lang ( @{$c->languages} ) {
        if (-d $c->path_to( 'root', @{$path_parts}, $lang) ) {
            $c->log->info(
                'Apparently this exists: ',
                $c->path_to( 'root', @{$path_parts}, $lang)
            );
            return $lang;
        }
    }

    # default to a generic english variant
    return 'i_default';
}

1;

__END__