Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

i18n::acceptlanguage(3pm) [debian man page]

I18N::AcceptLanguage(3pm)				User Contributed Perl Documentation				 I18N::AcceptLanguage(3pm)

NAME
I18N::AcceptLanguage - Matches language preference to available languages SYNOPSIS
use I18N::AcceptLanguage; my $supportedLanguages = [( 'en-us', 'fr' )]; my $acceptor = I18N::AcceptLanguage->new(); my $language = $acceptor->accepts($ENV{HTTP_ACCEPT_LANGUAGE}, $supportedLanguages); DESCRIPTION
I18N::AcceptLanguage matches language preference to available languages per rules defined in RFC 2616, section 14.4: HTTP/1.1 - Header Field Definitions - Accept-Language. PUBLIC METHODS
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: CLIENT_PREFERENCES A string in the same format defined in RFC 2616, quoted here: 1#( ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" ) [ "'" "q" "=" qvalue ] ) Examples: da, en-gb;q=0.8, en;q=0.7 en-us, ja, * SUPPORTED_LANGUAGES A reference to a list of language ranges supported by the server. new( [ OPTIONS ] ) Returns a new I18N::AcceptLanguage object. The method accepts the following key/value pair options: debug A boolean set to either 0 or 1. When set to 1, debug messages will be printed to STDOUT. The value of debug defaults to 0. defaultLanguage A string representing the server's default language choice. The value of defaultLanguage defaults to an empty string. 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 soft- ware 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. PRIVATE METHODS
debug( [ BOOLEAN ] ) A get/set method that returns the value of debug, set by the optional method argument. defaultLanguage( [ LANGUAGE ] ) A get/set method that returns the value of defaultLanguage, set by the optional method argument. strict( [ BOOLEAN ] ) A get/set method that returns the value of strict, set by the optional method argument. NOTES
Case Sensitivity Language matches are done in a case-insensitive manner but results are case-sensitive to the value found in the SUPPORTED_LANGUAGES list. AVAILABILITY
This module is available on CPAN worldwide and requires perl version 5.6.1 or higher be installed. AUTHORS
Christian Gilmore <cag@us.ibm.com> SEE ALSO
RFC 2616 COPYRIGHT
Copyright (C) 2003, 2004 International Business Machines Corporation and others. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the terms of the IBM Public License. perl v5.8.8 2005-04-11 I18N::AcceptLanguage(3pm)

Check Out this Related Man Page

HTML::FormHandler::TraitFor::I18N(3pm)			User Contributed Perl Documentation		    HTML::FormHandler::TraitFor::I18N(3pm)

NAME
HTML::FormHandler::TraitFor::I18N - localization VERSION
version 0.40013 language_handle, _build_language_handle Holds a Locale::Maketext (or other duck_type class with a 'maketext' method) language handle. The language handle is used to localize the error messages in the field's 'add_error' method. It's also used in various places in rendering to localize labels and button values, etc. The builder for this attribute gets the Locale::Maketext language handle from the environment variable $ENV{LANGUAGE_HANDLE}: $ENV{LANGUAGE_HANDLE} = HTML::FormHandler::I18N->get_handle('en_en'); ...or creates a default language handler using HTML::FormHandler::I18N. You can pass in an existing Locale::MakeText subclass instance or create one in a builder. In a form class: sub _build_language_handle { MyApp::I18N::abc_de->new } Passed into new or process: my $lh = MyApp::I18N::abc_de->new; my $form = MyApp::Form->new( language_handle => $lh ); If you do not set the language_handle, then Locale::Maketext and/or I18N::LangTags may guess, with unexpected results. You can use non-Locale::Maketext language handles, such as Data::Localize. There's an example of building a Data::Localize language handle in t/xt/locale_data_localize.t in the distribution. If you don't want a particular error message to go through localization, you can use 'push_errors' and 'push_form_errors' instead of 'add_error' and 'add_form_errors'. Example of getting the language handle from the Catalyst context (where the Catalyst context is passed in with 'ctx'): has '+language_handle' => ( builder => 'get_language_handle_from_ctx' ); sub get_language_handle_from_ctx { my $self = shift; return MyApp::I18N->get_handle( @{ $self->ctx->languages } ); } AUTHOR
FormHandler Contributors - see HTML::FormHandler COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Gerda Shank. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-25 HTML::FormHandler::TraitFor::I18N(3pm)
Man Page