This POD documents the deprecated legacy system (pre v0.06)
New code should use the more modern, efficient, and CLDR based Locales object system.
Locales::Language - (DEPRECATED use Locales instead) ISO two letter codes for language identification (ISO 639)
use Locale::Language; # use environment language my $lang = code2language ( 'en' ); # $lang gets 'English' my $code = language2code ( 'French' ); # $code gets 'fr' my @codes = all_language_codes(); my @names = all_language_names();
use utf8; use Locale::Language ( 'de' ); # use German language my $lang = code2language ( 'en' ); # $lang gets 'Englisch' my $code = language2code ( 'Französisch' ); # $code gets 'fr' my @codes = all_language_codes(); my @names = all_language_names(); # gets list of names in German # set default Language to French Locales::Language::setLocale ( 'fr' ); $lang = code2language ( 'en' ); # $lang gets 'Anglais' $code = language2code ( 'Français' ); # $code gets 'fr'
use utf8; require Locales::Language; my $am = new Locales::Language ( "am" ); my $de = new Locales::Language ( "de" ); print $am->getLocale, " => ", $am->code2language ( "en" ), " / ", $am->language2code ( "እንግሊዝኛ" ), "\n"; print $de->getLocale, " => ", $de->code2language ( "en" ), " / ", $de->language2code ( "Englisch" ), "\n"; my @codes = $am->all_language_codes(); my @deNames = $de->all_language_names();
use utf8; use Locale::Language ( 'de' ); # use German language my $de = new Locales::Language; print $de->getLocale, " => ", $de->code2language ( "en" ), " / ", $de->language2code ( "Englisch" ), "\n"; :
The Locale::Language module provides access to the ISO two-letter codes for identifying languages, as defined in ISO 639. You can either access the codes via the "conversion routines" (described below), or via the two functions which return lists of all language codes or all language names.
Locale::Language
There are two conversion routines: code2language() and language2code().
code2language()
language2code()
This function takes a two letter language code and returns a string which contains the name of the language identified. If the code is not a valid language code, as defined by ISO 639, then undef will be returned.
undef
$lang = code2language($code);
This function takes a language name and returns the corresponding two letter language code, if such exists. If the argument could not be identified as a language name, then undef will be returned.
$code = language2code('French');
The case of the language name is not important. See the section "KNOWN BUGS AND LIMITATIONS" below.
There are two functions which can be used to obtain a list of all language codes, or all language names:
all_language_codes()
Returns a list of all two-letter language codes. The codes are guaranteed to be all lower-case, and not in any particular order.
all_language_names()
Returns a list of all language names for which there is a corresponding two-letter language code. The names are capitalised, and not returned in any particular order.
Currently just supports the two letter language codes - there are also three-letter codes, and numbers. Would these be of any use to anyone?
Portions of the documentation of the module come directly from Locale::Language which was composed by Neil Bowers and contains the following copyright:
Copyright (C) 2002, Neil Bowers <neil@bowers.com>
Copyright (C) 1997-2001 Canon Research Centre Europe (CRE).
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Daniel Yacob, dyacob@cpan.org
Neil Bowers neil@bowers.com (Documentation)
ISO codes for identification of country (ISO 3166). Supports 2-letter, 3-letter, and numeric country codes.
Code for the representation of names of languages.
Home page for ISO 639-2.
Home page for ICU. The data used in Locales:: comes directly from the ICU CVS repository.
Provided with this package examples/language*.pl
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in ''Französisch''. Assuming UTF-8
To install Locales, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locales
CPAN shell
perl -MCPAN -e shell install Locales
For more information on module installation, please visit the detailed CPAN module installation guide.