Locale::Object::Language - language information objects




Locale::Object::Language allows you to create objects containing information about languages such as their ISO codes, the countries they're used in and so on.


    use Locale::Object::Language;

    my $eng = Locale::Object::Language->new( code_alpha3 => 'eng' );

    my $name        = $eng->name;
    my $code_alpha2 = $eng->code_alpha2;
    my $code_alpha3 = $eng->code_alpha3;
    my @countries = @{$eng->countries};

    my $gb  = Locale::Object::Country->new(  code_alpha2 => 'gb'  );

    print $eng->official($gb); 



    my $eng = Locale::Object::Language->new( code_alpha3 => 'eng' );

The new method creates an object. It takes a single-item hash as an argument - valid options to pass are ISO 3166 values - 'code', 'code_numeric' and 'name', and also 'country_code', which is an alpha2 country code (see Locale::Object::DB::Schemata for details on these). If you give a country code, a currency object will be created representing the currency of the country you specified.

The objects created are singletons; if you try and create a currency object when one matching your specification already exists, new() will return the original one.

name(), code_alpha2(), code_alpha3()

    my $name = $country->name;

These methods retrieve the values of the attributes in the object whose name they share.


    my $gb = Locale::Object::Country->new(  code_alpha2 => 'gb'  );

    print $eng->official($gb);  # prints 'true'

Give this method a Locale::Object::Country object, and it will return a 'true' or 'false' value for whether the country the object represents has the language represented by your Locale::Object::Language object as an official language.


The database of language information is not perfect by a long stretch. In particular, numerous comparatively obscure secondary or regional languages, such as in several African countries and India, that don't have ISO codes. (See note in Locale::Object::DB::Schemata about data sources.) Please send any corrections to the author.


Earle Martin <>


See the credits for Locale::Object.


Copyright 2003 Fotango Ltd. All rights reserved.

This module is released under the same license as Perl itself, and is provided on an "as is" basis. The author and Fotango Ltd make no warranties of any kind, either expressed or implied, as to the accuracy and/or utility of any results obtained from its use. However, if you do find something wrong with the results, please let the author know. Thanks.