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_METHODHTTP_ACCEPT_LANGUAGELANGUAGELC_ALLLC_MESSAGESLANG
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::LangTagsWin32::LocaleLocale::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 π
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