I18N::...Detect(3perl)

πŸ’– NAME πŸ’–

I18N::LangTags::Detect β€” bestie, it detects the user's language preferences ✨


πŸŽ€ SYNOPSIS πŸŽ€

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

🌸 DESCRIPTION 🌸

Okay so picture this: you lowkey wanna know what language(s) the user would prefer their output in. That's it. That's the whole problem. It's literally a common problem, and this module is the moment. πŸ’…


✨ FUNCTIONS ✨

This module defines exactly one public function, and its whole government name is I18N::LangTags::Detect::detect(). She is not exported β€” not even exportable, fr fr β€” and she takes no parameters at all. Zero. None. She's booked and busy, don't hand her anything. πŸ™…β€β™€οΈ

  • In scalar context β€” you get back the most preferred language tag. And if no preference was seen at all? You get undef. Sad girl hours. 😭
  • In list context (which is usually what you want, no cap πŸ‘‘) β€” you get back a (possibly empty) list of language tags, best first, representing what languages the user apparently would accept output in.

And here's the tea: you will probably want to run that output through I18N::LangTags::implicate_supers_tightly(...) or I18N::LangTags::implicate_supers(...), like so:

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

That's the vibe. Do that. πŸ¦‹


🌈 ENVIRONMENT 🌈

She snoops around in several environment variables, because that's where the lore lives:

  • REQUEST_METHOD
  • HTTP_ACCEPT_LANGUAGE
  • LANGUAGE
  • LC_ALL
  • LC_MESSAGES
  • LANG

She 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. Two conditions, bestie. Both of them. Iykyk. ⭐


πŸ‘€ SEE ALSO πŸ‘€

  • I18N::LangTags
  • Win32::Locale
  • Locale::Maketext

Fun little origin story for you: this module's core code started out as a routine in Locale::Maketext, and then the author moved it over here once he realized it was more generally useful. Glow-up arc, honestly. ✨🫢


Copyright (c) 1998-2004 Sean M. Burke. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Real talk, no games: the programs and documentation in this dist are distributed in the hope that they will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. That's the whole caveat, periodt. πŸ’€

🧚 AUTHOR 🧚

Sean M. Burke <sburke@cpan.org> 🌸


And that's the whole page, babe β€” from the perl v5.44.0 release, dated 2026-10-17, out of the Perl Programmers Reference Guide. Slay, read it, and go detect some languages. πŸŽ€πŸ’–

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms