NAME
App::CELL::Message - handle messages the user might see
VERSION
Version 0.141
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
EXPORTS AND PUBLIC METHODS
This module provides the following public functions and methods:
new
- construct aApp::CELL::Message
objecttext
- get text of an existing objectmax_size
- get maximum size of a given message code
DESCRIPTION
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 textlanguage
- message language (e.g., English)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.
PACKAGE VARIABLES
@supp_lang
)
The list of supported languages, specified by their respective language tags. Set by App::CELL->init, or might not be set at all.
See the W3C's "Language tags in HTML and XML" white paper for a detailed explanation of language tags:
http://www.w3.org/International/articles/language-tags/
And see here for list of all language tags:
http://www.langtag.net/registries/lsr-language.txt
@min_supp_lang
Minimal list of languages (tags) all applications using App::CELL
are required to support.
$language_tag
Language tag indicating which language messages are to be displayed in.
$mesg
The App::CELL::Message
module stores messages in a package variable, $mesg
(which is a hashref).
FUNCTIONS AND METHODS
new
Construct a message object. Takes a message code and, optionally, 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".
_stringify_args
Convert args into a string for error reporting
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 content of 'text' attribute, or "<NO_TEXT>" if it can't find any content.