NAME
Locale::Object - OO locale information
VERSION
0.6
DESCRIPTION
The Locale::Object
group of modules attempts to provide locale-related information in an object-oriented fashion. The information is collated from several sources and provided in an accompanying DBD::SQLite database.
At present, the modules are:
* Locale::Object - make compound objects containing country, currency and language objects
* Locale::Object::Country - objects representing countries
* Locale::Object::Continent - objects representing continents
* Locale::Object::Currency - objects representing currencies
* Locale::Object::Currency::Converter - convert between currencies
* Locale::Object::DB - does lookups for the modules in the database
* Locale::Object::Language - objects representing languages
For more information, see the documentation for those modules. The database is documented in docs/database.pod. Locale::Object itself can be used to create compound objects containing country, currency and language objects.
SYNOPSIS
use Locale::Object;
my $obj = Locale::Object->new(
country_code_alpha2 => 'gb',
currency_code => 'GBP',
language_code_alpha2 => 'en'
);
$obj->country_code_alpha2('af');
$obj->country_code_alpha3('afg');
$obj->currency_code('AFA');
$obj->currency_code_numeric('004');
$obj->language_code_alpha2('ps');
$obj->language_code_alpha3('pus');
$obj->language_name('Pushto');
METHODS
new()
my $obj = Locale::Object->new(
country_code_alpha2 => 'gb',
currency_code => 'GBP',
language_code_alpha2 => 'en'
);
Creates a new object. With no parameters, the object will be blank. Valid parameters match the method names that follow.
country_code_alpha2(), country_code_alpha3()
$obj->country_code_alpha2('af');
$obj->country_code_alpha3('afg');
Sets the country attribute in the object by alpha2 and alpha3 codes. Will create a new Locale::Object::Country object and set that as the attribute. Because Locale::Object::Country objects all have single instances, if one has already been created by that code, it will be reused when you do this.
country_code(), currency_code_numeric()
$obj->currency_code('AFA');
$obj->currency_code_numeric('004');
Serves the same purpose as the previous methods, only for the currency attribute, a Locale::Object::Currency object.
language_code_alpha2(), language_code_alpha3(), language_name()
$obj->language_code_alpha2('ps');
$obj->language_code_alpha3('pus');
$obj->language_name('Pushto');
Serves the same purpose as the previous methods, only for the language attribute, a Locale::Object::Language object.
Retrieving Attributes
country(), language(), currency()
While the foregoing methods can be used to set attribute objects, to retrieve those objects' own attributes you will have to use their own methods. The country()
, language()
and currency()
methods return the objects stored as those attributes, if they exist.
my $country_tzone = $country->timezone->name;
my $language_name = $obj->language->name;
my $currency_code = $obj->currency->code;
See Locale::Object::Country, Locale::Object::Language and Locale::Object::Currency for more details on the subordinate methods.
AUTHOR
Earle Martin <EMARTIN@cpan.org>
CREDITS
Original concept: Pierre Denis (PDENIS). I had much useful assistance from Pierre, Tom Insam (TOMI) - who contributed to my knowledge of DBI - and James Duncan (JDUNCAN). Most of the OO concepts involved I learnt from Damian Conway (DCONWAY)'s excellent book "Object Oriented Perl" (ISBN 1-884777-79-1).
COPYRIGHT
Copyright 2003 Fotango Ltd. All rights reserved. http://opensource.fotango.com/
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.
SEE ALSO
Locale::Codes, for simple conversions between names and ISO codes.