App::C...essage(3pm)
β¨ App::CELL::Message β¨ β handle messages the user might see π
okay bestie, welcome to the App::CELL::Message page from the User Contributed Perl Documentation era π«Ά this is the module that deals with messages β the little bits of text a user might actually lay eyes on π it handles localizing them, sizing them, and passing them around. let's get into it, no cap π
πΈ SYNOPSIS πΈ
use App::CELL::Message;
# server messages: pass message code only, message text
# will be localized to the site default language, if
# assertainable, or, failing that, in English
my $message = App::CELL::Message->new( code => 'FOOBAR' )
# and then we pass $message as an argument to
# App::CELL::Status->new
# client messages: pass message code and session id,
# message text will be localized according to the user's language
# preference setting
my $message = App::CELL::Message->new( code => 'BARBAZ',
session => $s_obj );
$msg_to_display = $message->App::CELL::Message->text;
# a message may call for one or more arguments. If so,
# include an 'args' hash element in the call to 'new':
args => [ 'FOO', 'BAR' ]
# they will be included in the message text via a call to
# sprintf
so basically: server messages just take a message code, and the text gets localized to the site default language if it's assertainable, or English if it's not π€·ββοΈ client messages take a message code plus a session id, and the text gets localized based on the user's own language preference π and if a message needs arguments? drop an args hash element into the new call and they get slotted in via a call to sprintf β¨
π EXPORTS AND PUBLIC METHODS π
this module hands you these public functions and methods, and they are iconic fr fr:
newβ constructs anApp::CELL::Messageobject π£textβ grabs the text off an existing object πmax_sizeβ grabs the maximum size of a given message code π
π DESCRIPTION π
An App::CELL::Message object is a reference to a hash containing some or all of these keys (aka attributes), bestie:
codeβ the message code (more on that below π)textβ the message texterrorβ the error (if any) related to this messagelanguageβ the message language (like, English, for example π)max_sizeβ the maximum number of characters this message is guaranteed not to exceed (and will be truncated to fit into) βοΈtruncatedβ boolean value: has the text been truncated or not
The info living in that hash comes from two places: the $mesg hashref right here in this module (peep CONSTANTS below) and the SQL database ποΈ The former is reserved for "system critical" messages, while the latter holds the messages users run into on the daily βοΈ System messages are English-only; only user messages are localizable, periodt π
π§ PACKAGE VARIABLES π§
$mesg
The App::CELL::Message module stores messages in a package variable, $mesg (which is, you guessed it, a hashref) π¦
@supp_lang
The list of supported languages π It gets set by $CELL->load from the value of CELL_SUPP_LANG
$def_lang
The defined, or default, language π― Set by $CELL->load from the value of CELL_DEF_LANG
π₯ FUNCTIONS AND METHODS π₯
supported_languages
Get a reference to the list of supported languages πβ¨
language_supported
Figure out if a given language is supported or not π΅οΈββοΈ
default_language
Return the default language π¬
new
Construct a message object π£ Takes a PARAMHASH containing, at minimum, a 'code' attribute, plus optionally other attributes like 'args' (a reference to an array of arguments). Returns a status object. If the status is ok, then the message object will be chillin' in the payload π¬ Check SYNOPSIS above for the vibe.
lang
Clones the message into another language π Returns a status object. On success, the new message object will be in the payload π
stringify
Generate a string representation of a message object using Data::Dumper π§Ύ
code
Accessor method for the 'code' attribute π
args
Accessor method for the 'args' attribute π§©
text
Accessor method for the 'text' attribute π Returns the content of the 'text' attribute, or "<NO_TEXT>" if it can't find any content π
bestie heads up: "<NO_TEXT>" is literally what it returns β no content, no vibes, just that string π
πΈ that's the whole page, you ate it πΈ
cute little sign-off for the record books: this is perl v5.34.0, dated 2022-07-17, and the manual page itself is App::C...essage(3pm) π mwah, go localize something pretty π¦β¨
π¦ where this page comes from
- debian bookworm: libapp-cell-perl 0.231-1 Β· BSD-3-Clause
- debian trixie: libapp-cell-perl 0.231-1 Β· BSD-3-Clause
- ubuntu noble: libapp-cell-perl 0.231-1 Β· BSD-3-Clause
- ubuntu resolute: libapp-cell-perl 0.231-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms