| 1 |
Lingua::Preferred |
| 2 |
|
| 3 |
Many web browsers let you specify which languages you understand. |
| 4 |
Then they negotiate with the web server to get documents in the best |
| 5 |
language possible. This is something similar in Perl. |
| 6 |
|
| 7 |
which_lang() takes a list of languages the user understands, such as |
| 8 |
qw(en es) and a list of those available on the server, such as qw(en fr |
| 9 |
de), and it returns the language to use. There is some fooling around |
| 10 |
with picking second-best 'dialects' of a language, for example if the |
| 11 |
user's language is en_IE and a page is available in en_US. |
| 12 |
|
| 13 |
acceptable_lang() takes a list of languages the user understands and a |
| 14 |
single language, and returns true iff that language is acceptable. |
| 15 |
Again it assumes that different dialects of a language are mutually |
| 16 |
comprehensible. |
| 17 |
|
| 18 |
Note: I created this module by packaging up some of my own code, but |
| 19 |
with hindsight I'm not sure it was a good idea. The world does not |
| 20 |
need another NIH way of doing language selections. It would be better |
| 21 |
to pick languages by adapting HTTP language negotiation or gettext. |
| 22 |
So I do not plan further development on this module except for |
| 23 |
bugfixes. |
| 24 |
|
| 25 |
Version 0.2.4: accept language choice 'C' (named after the Unix |
| 26 |
locale) to mean pick the first available language. |
| 27 |
|
| 28 |
* Copying |
| 29 |
|
| 30 |
Copyright 2001-2003 Ed Avis. This is free software; you may |
| 31 |
distribute it under the same terms as perl itself (either under the |
| 32 |
GNU General Public License, version 2 or at your option any later |
| 33 |
version); or under the Artistic License. |
| 34 |
|
| 35 |
-- Ed Avis, <[email protected]>, 2003-12-14 |