App::C...essage(3pm)

πŸ“¦
version 0.231 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

✨ 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 an App::CELL::Message object 🐣
  • 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 text
  • error β€” the error (if any) related to this message
  • language β€” 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