NAME
CGI::Lingua - Natural language choices for CGI programs
VERSION
Version 0.09
SYNOPSIS
CGI::Lingua provides a simple basis to determine which language to display a website in. The website tells CGI::Lingua which languages it supports. Based on that list CGI::Lingua tells the application which language the user would like to use.
use CGI::Lingua;
my $l = CGI::Lingua->new(supported => ['en', 'fr', 'en-gb', 'en-us']);
my $language = CGI::Lingua->language();
if ($language eq 'English') {
print '<P>Hello</P>';
} elsif($language eq 'French') {
print '<P>Bonjour</P>';
} else { # $language eq 'Unknown'
my $rl = CGI::Lingua->requested_language();
print "<P>Sorry for now this page is not available in $rl.</P>";
}
...
SUBROUTINES/METHODS
new
Creates a CGI::Lingua object. Takes one parameter: a list of languages, in RFC-1766 format, that the website supports. Language codes are of the form primary-code [ - country-code ] e.g. 'en', 'en-gb' for English and British English respectively.
For a list of primary-codes refer to ISO-936. For a list of country-codes refer to ISO-3166.
# We support English, French, British and American English, in that order
my $l = CGI::Lingua(supported => [('en', 'fr', 'en-gb', en-us')]);
language
Tells the CGI application what language to display its messages in. The language is the natural name e.g. 'English' or 'Japanese'.
sublanguage
Tells the CGI what variant to use e.g. 'United Kingdom'.
requested_language
Gives a human readable rendition of what language the user asked for whether or not it is supported.
AUTHOR
Nigel Horne, <njh at bandsman.co.uk>
BUGS
Please report any bugs or feature requests to bug-cgi-lingua at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Lingua. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc CGI::Lingua
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
Copyright 2010 Nigel Horne.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.