Locale::Language - ISO two letter codes for language identification |
Locale::Language - ISO two letter codes for language identification (ISO 639)
use Locale::Language; $lang = code2language('en'); # $lang gets 'English' $code = language2code('French'); # $code gets 'fr' @codes = all_language_codes(); @names = all_language_names();
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.
There are two conversion routines: code2language()
and language2code()
.
code2language()
undef
will be returned.
$lang = code2language($code);
language2code()
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 function which can be used to obtain a list of all language codes, or all language names:
all_language_codes()
all_language_names()
The following example illustrates use of the code2language()
function.
The user is prompted for a language code, and then told the corresponding
language name:
$| = 1; # turn off buffering print "Enter language code: "; chop($code = <STDIN>); $lang = code2language($code); if (defined $lang) { print "$code = $lang\n"; } else { print "'$code' is not a valid language code!\n"; }
Neil Bowers <neil@bowers.com>
Copyright (C) 2002, Neil Bowers.
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.
Locale::Language - ISO two letter codes for language identification |