.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "I18N::AcceptLanguage 3pm" .TH I18N::AcceptLanguage 3pm "2018-01-21" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" I18N::AcceptLanguage \- Matches language preference to available languages .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use I18N::AcceptLanguage; \& \& my $supportedLanguages = [( \*(Aqen\-us\*(Aq, \*(Aqfr\*(Aq )]; \& \& my $acceptor = I18N::AcceptLanguage\->new(); \& my $language = $acceptor\->accepts($ENV{HTTP_ACCEPT_LANGUAGE}, \& $supportedLanguages); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBI18N::AcceptLanguage\fR matches language preference to available languages per rules defined in \s-1RFC 2616,\s0 section 14.4: \s-1HTTP/1.1\s0 \- Header Field Definitions \- Accept-Language. .SH "PUBLIC METHODS" .IX Header "PUBLIC METHODS" .IP "accepts( \s-1CLIENT_PREFERENCES, SUPPORTED_LANGUAGES\s0 )" 2 .IX Item "accepts( CLIENT_PREFERENCES, SUPPORTED_LANGUAGES )" Returns the highest priority common language between client and server. If no common language is found, the defaultLanguage is returned. If defaultLanuage is also not set, an empty string is returned. The method expects two arguments: .RS 2 .IP "\s-1CLIENT_PREFERENCES\s0" 2 .IX Item "CLIENT_PREFERENCES" A string in the same format defined in \s-1RFC 2616,\s0 quoted here: .Sp .Vb 1 \& 1#( ( ( 1*8ALPHA *( "\-" 1*8ALPHA ) ) | "*" ) [ "\*(Aq" "q" "=" qvalue ] ) .Ve .Sp Examples: .Sp .Vb 1 \& da, en\-gb;q=0.8, en;q=0.7 \& \& en\-us, ja, * .Ve .IP "\s-1SUPPORTED_LANGUAGES\s0" 2 .IX Item "SUPPORTED_LANGUAGES" A reference to a list of language ranges supported by the server. .RE .RS 2 .RE .IP "new( [ \s-1OPTIONS\s0 ] )" 2 .IX Item "new( [ OPTIONS ] )" Returns a new I18N::AcceptLanguage object. The method accepts the following key/value pair options: .RS 2 .IP "debug" 2 .IX Item "debug" A boolean set to either 0 or 1. When set to 1, debug messages will be printed to \s-1STDOUT.\s0 The value of debug defaults to 0. .IP "defaultLanguage" 2 .IX Item "defaultLanguage" A string representing the server's default language choice. The value of defaultLanguage defaults to an empty string. .IP "strict" 2 .IX Item "strict" A boolean set to either 0 or 1. When set to 1, the software strictly conforms to the protocol specification. When set to 0, the software will perform a secondary, aggressive language match regardless of country (ie, a client asking for only en-gb will get back en-us if the server does not accept en-gb or en but does accept en-us). The last matching language in the supported languages list will be chosen. The value of strict defaults to 1. .RE .RS 2 .RE .SH "PRIVATE METHODS" .IX Header "PRIVATE METHODS" .IP "debug( [ \s-1BOOLEAN\s0 ] )" 2 .IX Item "debug( [ BOOLEAN ] )" A get/set method that returns the value of debug, set by the optional method argument. .IP "defaultLanguage( [ \s-1LANGUAGE\s0 ] )" 2 .IX Item "defaultLanguage( [ LANGUAGE ] )" A get/set method that returns the value of defaultLanguage, set by the optional method argument. .IP "strict( [ \s-1BOOLEAN\s0 ] )" 2 .IX Item "strict( [ BOOLEAN ] )" A get/set method that returns the value of strict, set by the optional method argument. .SH "NOTES" .IX Header "NOTES" .IP "Case Sensitivity" 2 .IX Item "Case Sensitivity" Language matches are done in a case-insensitive manner but results are case-sensitive to the value found in the \s-1SUPPORTED_LANGUAGES\s0 list. .SH "AVAILABILITY" .IX Header "AVAILABILITY" This module is available on \s-1CPAN\s0 worldwide and requires perl version 5.6.1 or higher be installed. .SH "AUTHORS" .IX Header "AUTHORS" Christian Gilmore .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1RFC 2616\s0 .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2003, 2004 International Business Machines Corporation and others. All Rights Reserved. .PP This module is free software; you can redistribute it and/or modify it under the terms of the \s-1IBM\s0 Public License.