The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MooseX::Types::Locale::Language - Locale::Language related constraints and coercions for Moose

VERSION

This document describes MooseX::Types::Locale::Language version 0.07.

SYNOPSIS

    {
        package Foo;

        use Moose;
        use MooseX::Types::Locale::Language qw(
            LanguageCode
            LanguageName
        );

        has 'code'
            => ( isa => LanguageCode, is => 'rw', coerce => 1 );
        has 'name'
            => ( isa => LanguageName, is => 'rw', coerce => 1 );

        __PACKAGE__->meta->make_immutable;
    }

    my $foo = Foo->new(
        code => 'JA',
        name => 'JAPANESE',
    );
    print $foo->code;   # 'ja'
    print $foo->name;   # 'Japanese'

DESCRIPTION

This module packages several Moose::Util::TypeConstraints with coercions, designed to work with the values of Locale::Language.

CONSTRAINTS AND COERCIONS

Alpha2Language

A subtype of Str, which should be defined in language code of ISO 639-1 alpha-2. If you turned coerce on, Str will be lower-case. For example, 'JA' will convert to 'ja'.

LanguageCode

Alias of Alpha2Language.

BibliographicLanguage

A subtype of Str, which should be defined in language code of ISO 639-2/B alpha-3. If you turned coerce on, Str will be lower-case. For example, 'CHI' will convert to 'chi'.

Alpha3Language

Alias of BibliographicLanguage.

TerminologicLanguage

A subtype of Str, which should be defined in language code of ISO 639-2/T alpha-3. If you turned coerce on, Str will be lower-case. For example, 'ZHO' will convert to 'zho'.

LanguageName

A subtype of Str, which should be defined in ISO 639-1 language name. If you turned coerce on, Str will be same case as canonical name. For example, 'JAPANESE' will convert to 'Japanese'.

NOTE

Code conversion is not supported

These coercions is not support code conversion. For example, from Alpha2Language to LanguageName.

    has language
        => ( is => 'rw', isa => LanguageName, coerce => 1 );

    ...

    $foo->language('en');   # does not convert to 'English'

If you want conversion, could you implement an individual language class with several attributes?

See /examples/complex.pl in the distribution for more details.

The type mapping of MooseX::Getopt

This module provides you the optional type mapping of MooseX::Getopt when MooseX::Getopt was installed.

LanguageCode, Alpha2Language and LanguageName are String ("=s") type.

SEE ALSO

INCOMPATIBILITIES

None reported.

TO DO

  • I may add grammatical aliases of constraints/coercions. For example, LanguageAsAlpha2 as existent Alpha2Language.

  • I may add namespased types. For example, 'Locale::Language::Alpha2' as export type Alpha2Language.

BUGS AND LIMITATIONS

No bugs have been reported.

Making suggestions and reporting bugs

Please report any found bugs, feature requests, and ideas for improvements to bug-moosex-types-locale-language at rt.cpan.org, or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=MooseX-Types-Locale-Language. I will be notified, and then you'll automatically be notified of progress on your bugs/requests as I make changes.

When reporting bugs, if possible, please add as small a sample as you can make of the code that produces the bug. And of course, suggestions and patches are welcome.

SUPPORT

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

    perldoc MooseX::Types::Locale::Language

You can also look for information at:

RT: CPAN's request tracker

http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Locale-Language

AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/MooseX-Types-Locale-Language

Search CPAN

http://search.cpan.org/dist/MooseX-Types-Locale-Language

CPAN Ratings

http://cpanratings.perl.org/dist/MooseX-Types-Locale-Language

VERSION CONTROL

This module is maintained using git. You can get the latest version from git://github.com/gardejo/p5-moosex-types-locale-language.git.

AUTHOR

MORIYA Masaki, alias Gardejo

<moriya at cpan dot org>, http://gardejo.org/

COPYRIGHT AND LICENSE

Copyright (c) 2009-2010 MORIYA Masaki, alias Gardejo

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

The full text of the license can be found in the LICENSE file included with this distribution.