App::CELL::Message - handle messages the user might see
# 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
# 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
This module provides the following public functions and methods:
- "new" - construct a
- "text" - get text of an existing object
- "max_size" - get maximum size of a given message
An App::CELL::Message object is a reference to a hash containing some or all of
the following keys (attributes):
- "code" - message code (see below)
- "text" - message text
- "error" - error (if any) related to this
- "language" - message language (e.g.,
- "max_size" - maximum number of characters this
message is guaranteed not to exceed (and will be truncated to fit into)
- "truncated" - boolean value: text has been
truncated or not
The information in the hash is sourced from two places: the $mesg hashref in
this module (see "CONSTANTS") and the SQL database. The former is
reserved for "system critical" messages, while the latter contains
messages that users will come into contact with on a daily basis. System
messages are English-only; only user messages are localizable.
The "App::CELL::Message" module stores messages in a package variable,
$mesg (which is a hashref).
List of supported languages. Set by "$CELL->load" from the value of
The defined, or default, language. Set by "$CELL->load" from the
value of CELL_DEF_LANG
Get reference to list of supported languages.
Determine if a given language is supported.
Return the default language.
Construct a message object. Takes a PARAMHASH containing, at least, a 'code'
attribute as well as, optionally, other attributes such as 'args' (a reference
to an array of arguments). Returns a status object. If the status is ok, then
the message object will be in the payload. See "SYNOPSIS".
Clones the message into another language. Returns a status object. On success,
the new message object will be in the payload.
Generate a string representation of a message object using Data::Dumper.
Accessor method for the 'code' attribute.
Accessor method for the 'args' attribute.
Accessor method for the 'text' attribute. Returns content of 'text' attribute,
or "<NO_TEXT>" if it can't find any content.