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) = @_;

          'first_valid_locale language list: '
        . "@{$c->languages}"

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

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



=head1 NAME

Parley::App::I18N - i18n helper functions


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

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

=head1 SEE ALSO

L<Parley::Controller::Root>, L<Catalyst>

=head1 AUTHOR

Chisel Wright C<< <> >>

=head1 LICENSE

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