I18N::LangTags::Detect(3perl)

I18N::LangTags::Detect3perl

Detect the user's language preferences

Usage

  use I18N::LangTags::Detect;
  my @user_wants = I18N::LangTags::Detect::detect();

Overview

It is a common problem to want to detect what language(s) the user would prefer output in.

Functions

This module defines one public function, I18N::LangTags::Detect::detect(). This function is not exported (nor is even exportable), and it takes no parameters.

In scalar context, the function returns the most preferred language tag (or undef if no preference was seen).

In list context (which is usually what you want), the function returns a (possibly empty) list of language tags representing (best first) what languages the user apparently would accept output in. You will probably want to pass the output of this through I18N::LangTags::implicate_supers_tightly(...) or I18N::LangTags::implicate_supers(...), like so:

  my @languages =
    I18N::LangTags::implicate_supers_tightly(
      I18N::LangTags::Detect::detect()
    );

Environment

This module looks at several environment variables: REQUEST_METHOD, HTTP_ACCEPT_LANGUAGE, LANGUAGE, LC_ALL, LC_MESSAGES, and LANG.

It will also use the Win32::Locale module, if it's installed and IGNORE_WIN32_LOCALE is not set to a true value in the environment.

Releases

11 releases since Debian 4.0 (Etch); the text changed 10 times.

  1. 4.0
  2. 5.0
  3. 6.0
  4. 7
  5. 8
  6. 9
  7. 10
  8. 11
  9. 12
  10. 13
  11. Arch

Author

Sean M. Burke "[email protected]"

From perl 5.44.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.