4 Locale::Language - ISO two letter codes for language identification (ISO 639)
10 $lang = code2language('en'); # $lang gets 'English'
11 $code = language2code('French'); # $code gets 'fr'
13 @codes = all_language_codes();
14 @names = all_language_names();
19 The C<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 L<conversion routines> (described below),
22 or via the two functions which return lists of all language codes or
26 =head1 CONVERSION ROUTINES
28 There are two conversion routines: C<code2language()> and C<language2code()>.
34 This function takes a two letter language code and returns a string
35 which contains the name of the language identified. If the code is
36 not a valid language code, as defined by ISO 639, then C<undef>
39 $lang = code2language($code);
43 This function takes a language name and returns the corresponding
44 two letter language code, if such exists.
45 If the argument could not be identified as a language name,
46 then C<undef> will be returned.
48 $code = language2code('French');
50 The case of the language name is not important.
51 See the section L<KNOWN BUGS AND LIMITATIONS> below.
58 There are two function which can be used to obtain a list of all
59 language codes, or all language names:
63 =item C<all_language_codes()>
65 Returns a list of all two-letter language codes.
66 The codes are guaranteed to be all lower-case,
67 and not in any particular order.
69 =item C<all_language_names()>
71 Returns a list of all language names for which there is a corresponding
72 two-letter language code. The names are capitalised, and not returned
73 in any particular order.
80 The following example illustrates use of the C<code2language()> function.
81 The user is prompted for a language code, and then told the corresponding
84 $| = 1; # turn off buffering
86 print "Enter language code: ";
87 chop($code = <STDIN>);
88 $lang = code2language($code);
91 print "$code = $lang\n";
95 print "'$code' is not a valid language code!\n";
98 =head1 KNOWN BUGS AND LIMITATIONS
104 In the current implementation, all data is read in when the
105 module is loaded, and then held in memory.
106 A lazy implementation would be more memory friendly.
110 Currently just supports the two letter language codes -
111 there are also three-letter codes, and numbers.
112 Would these be of any use to anyone?
120 =item Locale::Country
122 ISO codes for identification of country (ISO 3166).
123 Supports 2-letter, 3-letter, and numeric country codes.
127 ISO codes for identification of written scripts (ISO 15924).
129 =item Locale::Currency
131 ISO three letter codes for identification of currencies and funds (ISO 4217).
133 =item ISO 639:1988 (E/F)
135 Code for the representation of names of languages.
137 =item http://lcweb.loc.gov/standards/iso639-2/langhome.html
139 Home page for ISO 639-2.
146 The language names are encoded in UTF-8. (Currently this matters
147 only for two languages: Norwegian Bokmål, and Volapük.)
152 Neil Bowers E<lt>neil@bowers.comE<gt>
156 Copyright (C) 2002, Neil Bowers.
158 Copyright (c) 1997-2001 Canon Research Centre Europe (CRE).
160 This module is free software; you can redistribute it and/or
161 modify it under the same terms as Perl itself.