1Locale::Language(3pm)  Perl Programmers Reference Guide  Locale::Language(3pm)
2
3
4

NAME

6       Locale::Language - ISO two letter codes for language identification
7       (ISO 639)
8

SYNOPSIS

10           use Locale::Language;
11
12           $lang = code2language('en');        # $lang gets 'English'
13           $code = language2code('French');    # $code gets 'fr'
14
15           @codes   = all_language_codes();
16           @names   = all_language_names();
17

DESCRIPTION

19       The "Locale::Language" module provides access to the ISO two-letter
20       codes for identifying languages, as defined in ISO 639. You can either
21       access the codes via the "conversion routines" (described below), or
22       via the two functions which return lists of all language codes or all
23       language names.
24

CONVERSION ROUTINES

26       There are two conversion routines: "code2language()" and
27       "language2code()".
28
29       code2language()
30           This function takes a two letter language code and returns a string
31           which contains the name of the language identified. If the code is
32           not a valid language code, as defined by ISO 639, then "undef" will
33           be returned.
34
35               $lang = code2language($code);
36
37       language2code()
38           This function takes a language name and returns the corresponding
39           two letter language code, if such exists.  If the argument could
40           not be identified as a language name, then "undef" will be
41           returned.
42
43               $code = language2code('French');
44
45           The case of the language name is not important.  See the section
46           "KNOWN BUGS AND LIMITATIONS" below.
47

QUERY ROUTINES

49       There are two function which can be used to obtain a list of all
50       language codes, or all language names:
51
52       "all_language_codes()"
53           Returns a list of all two-letter language codes.  The codes are
54           guaranteed to be all lower-case, and not in any particular order.
55
56       "all_language_names()"
57           Returns a list of all language names for which there is a
58           corresponding two-letter language code. The names are capitalised,
59           and not returned in any particular order.
60

EXAMPLES

62       The following example illustrates use of the "code2language()"
63       function.  The user is prompted for a language code, and then told the
64       corresponding language name:
65
66           $| = 1;    # turn off buffering
67
68           print "Enter language code: ";
69           chop($code = <STDIN>);
70           $lang = code2language($code);
71           if (defined $lang)
72           {
73               print "$code = $lang\n";
74           }
75           else
76           {
77               print "'$code' is not a valid language code!\n";
78           }
79

KNOWN BUGS AND LIMITATIONS

81       ·   In the current implementation, all data is read in when the module
82           is loaded, and then held in memory.  A lazy implementation would be
83           more memory friendly.
84
85       ·   Currently just supports the two letter language codes - there are
86           also three-letter codes, and numbers.  Would these be of any use to
87           anyone?
88

SEE ALSO

90       Locale::Country
91           ISO codes for identification of country (ISO 3166).  Supports
92           2-letter, 3-letter, and numeric country codes.
93
94       Locale::Script
95           ISO codes for identification of written scripts (ISO 15924).
96
97       Locale::Currency
98           ISO three letter codes for identification of currencies and funds
99           (ISO 4217).
100
101       ISO 639:1988 (E/F)
102           Code for the representation of names of languages.
103
104       http://lcweb.loc.gov/standards/iso639-2/langhome.html
105           Home page for ISO 639-2.
106

AUTHOR

108       Neil Bowers <neil@bowers.com>
109
111       Copyright (C) 2002-2004, Neil Bowers.
112
113       Copyright (c) 1997-2001 Canon Research Centre Europe (CRE).
114
115       This module is free software; you can redistribute it and/or modify it
116       under the same terms as Perl itself.
117
118
119
120perl v5.12.4                      2011-06-07             Locale::Language(3pm)
Impressum