CHips L MINI SHELL

CHips L pro

Current Path : /proc/3/task/3/cwd/usr/local/Locale-MakePhrase-0.5/blib/man3/
Upload File :
Current File : //proc/3/task/3/cwd/usr/local/Locale-MakePhrase-0.5/blib/man3/Locale::MakePhrase.3pm

.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.13)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.el \{\
.    de IX
..
.\}
.\" ========================================================================
.\"
.IX Title "Locale::MakePhrase 3"
.TH Locale::MakePhrase 3 "2006-03-20" "perl v5.10.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Locale::MakePhrase \- Language translation facility
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
These group of modules are used to translate application text strings,
which may or may not include values which also need to be translated,
into the prefered language of the end-user.
.PP
Example:
.PP
.Vb 12
\&  use Locale::MakePhrase::BackingStore::Directory;
\&  use Locale::MakePhrase;
\&  my $bs = new Locale::MakePhrase::BackingStore::Directory(
\&    directory => \*(Aq/some/path/to/language/files\*(Aq,
\&  );
\&  my $mp = new Locale::MakePhrase(
\&    language => \*(Aqen_AU\*(Aq,
\&    backing_store => $bs,
\&  );
\&  ...
\&  my $color_count = 1;
\&  print $mp\->translate("Please select [_1] colors.",$color_count);
.Ve
.PP
Output:
.PP
.Vb 1
\&  Please select a colour.
.Ve
.PP
Notice that a) the word 'color' has been localised to Australian
English, and b) that the argument has influenced the resultant output
text to take into account the display of the singular version.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This aim of these modules are to implement run-time evaluation of an
input phrase, including program arguments, and have it generate a
suitable output phrase, in the language and encoding specified by the
user of the application.
.PP
Since this problem has been around for some time, there are a number
of sources of useful information available on the web, which describes
why this problem is hard to solve.  The problem with most existing
solutions is that each design suffers some form of limitation, often
due to the designer thinking that there are enough commonalities
between all/some langugaes that these commonalities can be factored
into a various rules which can be implemented in programming code.
.PP
However, each language has it own history and evolution. Thus it is
pointless to compare two different languages unless they have a common
history and a common character set.
.PP
\&\fIBefore\fR continuing to read this document, you really should read the
following info on the Locale::Maketext Perl module:
.PP
.Vb 1
\&  http://search.cpan.org/~sburke/Locale\-Maketext\-1.08/lib/Locale/Maketext.pod
.Ve
.PP
and at the slides presented here:
.PP
.Vb 1
\&  http://www.autrijus.org/webl10n/
.Ve
.PP
The Locale::MakePhrase modules are based on a design similar to the
Locale::Maketext module, except that this new implementation has
taken a different approach, that being...
.PP
Since it is possible (and quite likely) that the application will need
to be able to understand the language rules of any specific language,
we want to use a run-time evaluation of the rules that a linguist
would use to convert one language to another.  Thus we have coined the
term \fIlinguistic rules\fR as a means to describe this technique.  These
rules are used to decide which piece of text is displayed, for a given
input text and arguments.
.SH "REQUIREMENTS"
.IX Header "REQUIREMENTS"
The Locale::MakePhrase module was initially designed to meet the
requirements of a web application (as opposed to a desktop
application), which may display many languages in the \s-1HTML\s0 form at any
given instance.
.PP
Its design is modelled on a similar design of using language lexicons,
which is in use in the existing Locale::Maketext Perl module.  The
reason for building a new module is because:
.IP "\(bu" 2
We wanted to completely abstract the language rule capability, to be
programming language agnostic so that we could re-implement this
module in other programming languages.
.IP "\(bu" 2
We needed run-time evaluation of the rules, since the translations
may be updated at any time; new rules may be added whenever there is
some ambigutiy in the existing phrase.  Also, we didn't want to
re-start the application whenever we updated a rule.
.IP "\(bu" 2
We would like to support various types of storage mechanisms for the
translations.  The origonal design constraint prefered the use of a
PostgreSQL database to hold the translations \- most existing language
translation systems use flat files.
.IP "\(bu" 2
We want to store/manipulate the current text phrase, only encoded in
\&\s-1UTF\-8\s0 (ie: we dont want to store the text in a locale-specific
encoding).  This allows us to output text to any other character set.
.PP
As an example of application usage, it is possible for a Hebrew
speaking user to be logged into a web-form which contains Japanese
data. As such they will see:
.IP "\(bu" 2
Menus and tooltips will be translated into the users' language (ie: Hebrew).
.IP "\(bu" 2
Titles will be in the language of the dataset (ie: Japanese).
.IP "\(bu" 2
Some of the data was in Latin character set (ie: English).
.IP "\(bu" 2
If the user prefered to see the page as \s-1RTL\s0 rather than \s-1LTR\s0, the page
was altered to reflect this preference.
.SH "BACKGROUND"
.IX Header "BACKGROUND"
When implementing any new software, it is necessary to understand
the problem domain.  In the case of language translation, there
are a number of requirements that we can define:
.IP "1." 4
Quite a few people speak multiple languages; we would like the
language translation system to use the users preferred language
localisation, or if we don't know which language that is, try to make
an approximate guess, based on application capabilites.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
In a web-browser, the user normally sets their prefered language/dialect.
The browser normally sends this information to a web-server during the
request for a page.  The server may choose to show the page contents in
the language the user prefers.
.RE
.RS 4
.RE
.IP "2." 4
Since some people speak multiple languages, the application may not
have been localised to their prefered localisation.  We should try to
fallback to using a language which is similar.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
If there are no Spanish translations available, we should fallback
to Mexican, since Mexican and Spanish have many words in common.
.RE
.RS 4
.RE
.IP "3." 4
Some languages support the notion of a dialect for that language.  A
good example is that the English language is used in many
countries, but countries such as the United States, Australia and
Great Britain each have their own localised version ie. the dialect is
specified as the country or region.  The language translation
mechanism needs to be able to use the users' preferred dialect when
looking up the text to display.  If no translation is found, then it
should fall back to the parent language.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
The language/dialect of Australia is defined as 'en_AU' \- when we
lookup a text translation, if we fail we should try to lookup the 'en'
translation.
.RE
.RS 4
.RE
.IP "4." 4
Some languages are written using a script which displays its
output as right-to-left text (as used by Arabic, Hebrew, etc), rather
than left-to-right text (as used by English, Latin, Greek, etc).  The
language translation mechanism should allow the text display mechanism
to change the text direction if that is a requirement (which is
another reason for mandating the use of \s-1UTF\-8\s0).
.IP "5." 4
The string to be translated should support the ability to re-order
the wording of the text.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
In English we would normally say something like \*(L"Please enter your
name\*(R"; in Japanese the equivalent translation would be something like
\&\*(L"Enter your name, please\*(R" (although it would be in Japanese, not
English).
.RE
.RS 4
.RE
.IP "6." 4
The text translation mechanism should support the ability to show
arguments supplied to the string (by the application), within the
correct context of the meaning of the string.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
We could say something like \*(L"You selected 4 balls\*(R" (where the number 4
is program dependant); in another language you may want to say the
equivalent of \*(L"4 balls selected\*(R".
.RE
.RS 4
.Sp
Notice that the numeric position has moved from being the third
mnemonic, to being the first mnemonic.  The requirement is that we
would like to be able to rearrange the order/placement of any
mnemonic (including any program arguments).
.RE
.IP "7." 4
We would like to be able to support an arbitrary number of argument
replacements.  We shouldn't be limited in the number of replacements
that need to occur, for any given number program arguments.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
We want to have an unlimited number of placeholders as exemplified
by the string \*(L"Select _\|_ balls, _\|_ bats, _\|_ wickets, plus choose _\|_
people, _\|_\|_ ...\*(R" and so on.
.RE
.RS 4
.RE
.IP "8." 4
Most program arguments that are given to strings are in numeric
format (i.e. they are a number).  We would also like to support
arguments which are text strings, which themselves should be open to
language translation (but only after rule evaluation).  The purpose
being that the output phrase should make sense within the current
context of the application.
.IP "9." 4
In a lot of languages there is the concept of singular and plural.
While in other languages there is no such concept, while in others
still there is the concept of duality.  There is also the concept that
a phrase can be descriptive when discussing the zero of something.
Thus we want to display a specific phrase, depending on the value of
an argument.
.RS 4
.IP "Eg:" 4
.IX Item "Eg:"
In English, the following text \*(L"Selected _\|_ files\*(R" has multiple
possible outputs, depending on the program value; we can have:
.Sp
.Vb 4
\& 0 case: "No files selected" \- no numeric value
\& 1 case: "One file selected" \- \*(Aqfiles\*(Aq is singular
\& 2 case: "Selected two files" \- the \*(Aq_\|_\*(Aq is a text value, not a number
\& more than 2 case: "Lots of selections" \- no direct comparison to the original text
.Ve
.RE
.RS 4
.Sp
\&...as we can see, this is just for translating a single text
string, from English to English.
.Sp
To counter this problem, the translation system needs to be able
to apply linguistic rules to the original text, so that it can
evaluate which piece of text should be displayed, given the current
context and program argument.
.RE
.IP "10." 4
When updating a specific phrase for language translation, the next
screen re-draw should show the new translation text. Thus translations
need to be dynamically changeable, and run-time configurable.
.SH "INTERNAL TEXT ENCODING"
.IX Header "INTERNAL TEXT ENCODING"
This module uses \s-1UTF\-8\s0 text encoding internally, thus it requires a
minimum of Perl 5.8.  So, for any given application string and user
language combination, we require the backing store look-up the
combination, then return a list of Locale::MakePhrase::LanguageRule
objects, which must be created with the key and translated strings
being stored in the \s-1UTF\-8\s0 encoding.
.PP
Thus, to simplify the string-load functionality, we recommend to load
/ store the translated strings as \s-1UTF\-8\s0 encoded strings.  See
Locale::MakePhrase::BackingStore for more information.
.IP "ie." 4
.IX Item "ie."
The PostgreSQL backing store assumes that the database instance
stores strings in the \s-1UNICODE\s0 encoding (rather than, say, \s-1ASCII\s0); this
avoids the need to translate every string when we load it.
.SH "OUTPUT TEXT ENCODING"
.IX Header "OUTPUT TEXT ENCODING"
Locale::MakePhrase uses \s-1UTF\-8\s0 encoding internally, as described
above. This is also the default output encoding.  You can choose to
have a different output encoding, such as \s-1ISO\-8859\-1\s0.
.PP
Normlly, if the output display mechanism can display \s-1UNICODE\s0 (encoded as
\&\s-1UTF\-8\s0), then text will be rendered in the correct language and correct
text direction (ie. left-to-right or right-to-left).
.PP
By supplying the encoding as a constructor argument, Locale::MakePhrase
will transpose the translated text from \s-1UTF\-8\s0, into your output-specific
encoding (using the Encode module).  This is useful in cases where
font support within an application, hasn't yet evolved to the same
level as a language-specific font.
.PP
See the Encode module for a list of available output encodings.
.PP
Default output character set encoding: \fB\s-1UTF\-8\s0\fR
.SH "WHAT ARE LINGUISTIC RULES?"
.IX Header "WHAT ARE LINGUISTIC RULES?"
Since the concept of a linguistic rule is at the heart of this
translation module, its documentation is located in Locale::MakePhrase::RuleManager.
It explains the syntax of the rule expressions, how rules are sorted and
selected, as well as the operators and functions that are available
within the expressions.  You should read that information, before
continuing.
.IP "Available operators:" 2
.IX Item "Available operators:"
\&\fB==\fR, \fB!=\fR, \fB<\fR, \fB>\fR, \fB<=\fR, \fB>=\fR, \fBeq\fR, \fBne\fR
.IP "Available functions:" 2
.IX Item "Available functions:"
\&\fBdefined(x)\fR, \fBlength(x)\fR, \fBint(x)\fR, \fBabs(n)\fR, \fBlc(s)\fR, \fBuc(s)\fR,
\&\fBleft(s,n)\fR, \fBright(s,n)\fR, \fBsubstr(s,n)\fR, \fBsubstr(s,n,r)\fR
.SH "Object API"
.IX Header "Object API"
The following methods are part of the Locale::MakePhrase object \s-1API:\s0
.SS "\fInew()\fP"
.IX Subsection "new()"
Construct new instance of Locale::MakePhrase object.  Takes the
following named parameters (ie: via a hash or hashref):
.ie n .IP """language""" 2
.el .IP "\f(CWlanguage\fR" 2
.IX Item "language"
.PD 0
.ie n .IP """languages""" 2
.el .IP "\f(CWlanguages\fR" 2
.IX Item "languages"
.PD
Specify one or more languages which are used for locating the
correct language string (all forms are supported; first found is used).
.Sp
They take either a string (eg 'en'), a comma-seperated list (eg
\&'en_AU, en_GB') or an array of strings (eg ['en_AU','en_GB']).
.Sp
The order specified, is the order that phrases are looked up.  These
strings go through a manipulation process (using the Perl module
I18N::LangTags) of:
.RS 2
.IP "1." 3
The strings are converted to \s-1RFC3066\s0 language tags; these become
the primary tags.
.IP "2." 3
Superordinate tags are retrieved for each primary tag.
.IP "3." 3
Alternates of the primary tags are then retrieved.
.IP "4." 3
Panic language tags are retrieved for each primary tag (if enabled).
.IP "5." 3
The fallback language is retrieved (see 'fallback language').
.IP "6." 3
Duplicate language tags are removed.
.IP "7." 3
All tags are converted to lowercase, and '\-' are changed to '_'.
.RE
.RS 2
.Sp
This leaves us with a list of at least the fallback language.
.RE
.ie n .IP """charset""" 2
.el .IP "\f(CWcharset\fR" 2
.IX Item "charset"
.PD 0
.ie n .IP """encoding""" 2
.el .IP "\f(CWencoding\fR" 2
.IX Item "encoding"
.PD
This option (both forms are supported; first found is used) allows you
to change the output character set encoding, to something other than
\&\s-1UTF\-8\s0, such as \s-1ISO\-8859\-1\s0.
.Sp
See \s-1ENCODING\s0 for more information.
.ie n .IP """backing_store""" 2
.el .IP "\f(CWbacking_store\fR" 2
.IX Item "backing_store"
Takes either a reference to a backing store instance, or to a string
which can be used to dynamically construct the instance.
.Sp
The final backing store instance must have a type of Locale::MakePhrase::BackingStore.
.Sp
Default: use a Locale::MakePhrase::BackingStore
.ie n .IP """rule_manager""" 2
.el .IP "\f(CWrule_manager\fR" 2
.IX Item "rule_manager"
Takes either a reference to a rule manager instance, or to a string
which can be used to dynamically construct the instance.
.Sp
The final manager instance must have a type of Locale::MakePhrase::RuleManager.
.Sp
Default: use a Locale::MakePhrase::RuleManager
.ie n .IP """malformed_character_mode""" 2
.el .IP "\f(CWmalformed_character_mode\fR" 2
.IX Item "malformed_character_mode"
Perl normally outputs \ex{\s-1HH\s0} for malformed characters (or \ex{\s-1HHHH\s0},
\&\ex{\s-1HHHHHH\s0}, etc. for wide characters).  Setting this value, changes
the behaviour to output alternative character entity formats.
.Sp
Note that if you are using Locale::MakePhrase to generate strings
used within web pages / \s-1HTML\s0, you should set this parameter to
\&\f(CW\*(C`Locale::MakePhrase\->MALFORMED_MODE_HTML\*(C'\fR.
.ie n .IP """numeric_format""" 2
.el .IP "\f(CWnumeric_format\fR" 2
.IX Item "numeric_format"
This option allows the user to control how numbers are output.  You
can set the output to be one of a number of forms of stringification
defined in Locale::MakePhrase::Numeric, eg:
.RS 2
.IP "'.', ',', '(', ')'" 2
Place comma seperators before every third digit; use brackets for
negative, as in: (10,000,000.1)
.RE
.RS 2
.Sp
This takes either a string format or an array reference containing
the format.
.Sp
Default: dont format; show decimal as full-stop
.RE
.ie n .IP """die_on_bad_translation""" 2
.el .IP "\f(CWdie_on_bad_translation\fR" 2
.IX Item "die_on_bad_translation"
Set this option to true to make Locale::MakePhrase die if the
translated string is incorrectly formatted (eg: too many argument
place holders are specified) or the expression is not valid.  The
alternative is to output the phrase \fB<\s-1INVALID\s0 \s-1TRANSLATION\s0>\fR
or \fB<\s-1INVALID\s0 \s-1EXPRESSION\s0>\fR.
.Sp
Die'ing here means that translations have the ability to 
abort your code.  If you dont have control over the quality of the
phrases added to your dictionary, you should probably use the default
behaviour.
.Sp
Note that an invalid expression or translation generates a warning to
\&\s-1STDERR\s0.
.Sp
Default: dont die; output the appropriate error phrase
.ie n .IP """translate_arguments""" 2
.el .IP "\f(CWtranslate_arguments\fR" 2
.IX Item "translate_arguments"
Set this option to false to make Locale::MakePhrase not translate
the applied arguments, before applying them to the output of the
engine.  This saves you from having to call \fItranslate()\fR for each
argument, within your own code.
.Sp
Default: do translate arguments
.ie n .IP """add_newline""" 2
.el .IP "\f(CWadd_newline\fR" 2
.IX Item "add_newline"
Set this option to true to make Locale::MakePhrase automatically
add newline characters to the end of every translated string.  The
reason for having this is to allow your translation-key to not require
the OS-dependent newline character(s), and to not require newline
character(s) on the target-translation.
.Sp
Note that the \s-1API\s0 provides alternate method calls so as to allow
you to add newline character(s) as necessary.
.Sp
Default: dont add any newline characters
.ie n .IP """panic_language_lookup""" 2
.el .IP "\f(CWpanic_language_lookup\fR" 2
.IX Item "panic_language_lookup"
Set this option to true to make Locale::MakePhrase load 'panic'
languages as defined by \*(L"panic_languages\*(R" in I18N::LangTags.  Basically
it provides a mechanism to allow the engine to return a language
string from languages which has a similar heritage to the primary
language(s), if a translation from the primary language hasn't been
found.
.Sp
eg: Spanish has a similar heritage as Italian, thus if no translations
are found in Italian, then Spanish translations will be used.
.Sp
Default: dont lookup panic-languages
.IP "Notes:" 2
.IX Item "Notes:"
If the arguments aren't a hash or hashref, then we assume that the
arguments are languages tags.
.Sp
If you dont supply any language, the fallback language will be used.
.Sp
Default language: \fBen\fR
.ie n .SS "$self init([...])"
.el .SS "\f(CW$self\fP init([...])"
.IX Subsection "$self init([...])"
Allow sub-class a chance to control construction of the object.  You
must return a reference to \f(CW$self\fR, to 'allow' the construction to
complete.
.PP
At this point of construction you can call \f(CW\*(C`$self\->options()\*(C'\fR
which returns a reference to the current constructor options.  This
allows you to add/modify any existing options; for example you may
want to inject something specific...
.ie n .SS "$string context_translate($context, $string [, ...])"
.el .SS "\f(CW$string\fP context_translate($context, \f(CW$string\fP [, ...])"
.IX Subsection "$string context_translate($context, $string [, ...])"
[ \f(CW$context\fR is either a text string or an object reference (which
then gets stringified into its class name). ]
.PP
This is a primary entry point; call this with your application
context, your string and any program arguments which need to be
translated.  Note however that in most cases you will most likely want
to call the translate function
instead; see below.
.PP
In some cases you will find that you will use the same text phrase in
one part of your application, in a seperate part of your application,
but the meaning of the phrase is different (due to the different
application context); supplying a context will allow your backing
store to use the extra context information, to return the correct
language rules.
.PP
The steps involved in a string translation are:
.IP "1." 3
Fetch all possible translation rules for all language tags (including
alternates and the fallbacks), from the backing store.  The store will
return a list reference of LanguageRule objects.
.IP "2." 3
Sort the list based on the implementation defined in the
Locale::MakePhrase::RuleManager module.
.IP "3." 3
The the rule instance for which the rule-expression evaluates to \fBtrue\fR
for the supplied program arguments (if there is no expression, the rule
is always true).
.IP "4." 3
If no rules have been selected, then make a rule from the input string.
.IP "5." 3
Apply the program arguments to the rules' translated text.  If the
argument is a text phrase, it (optionally) undergoes the language
translation procedure.  If the argument is numeric, it is formatted by
one of your language sub-classes, or the Locale::MakePhrase::Numeric
module.
.IP "6." 3
We apply the output character set encoding to convert the text from
\&\s-1UTF\-8\s0 into the prefered character set.  If the output encoding is \s-1UTF\-8\s0
(thus matching the internal encoding), this item does nothing.
.ie n .SS "$string translate($string [, ...])"
.el .SS "\f(CW$string\fP translate($string [, ...])"
.IX Subsection "$string translate($string [, ...])"
This is a primary entry point; call this with your string and any
program arguments which need to be translated.
.PP
This function is a wrapper around the \f(CW\*(C`context_translate\*(C'\fR function,
where the context is set to undef (which is usually what you want).
.ie n .SS "$string context_translate_ln($context, $string [, ...])"
.el .SS "\f(CW$string\fP context_translate_ln($context, \f(CW$string\fP [, ...])"
.IX Subsection "$string context_translate_ln($context, $string [, ...])"
This is a primary entry point; call this with your context, string and
any program arguments which need to be translated.
.PP
This function is a wrapper around the \f(CW\*(C`context_translate\*(C'\fR function,
but this adds newline character(s) to the output.
.ie n .SS "$string translate_ln($string [, ...])"
.el .SS "\f(CW$string\fP translate_ln($string [, ...])"
.IX Subsection "$string translate_ln($string [, ...])"
This is a primary entry point; call this with your string and any
program arguments which need to be translated.
.PP
As above, this function is a wrapper around the \f(CW\*(C`context_translate\*(C'\fR
function, where the context is set to undef, but this adds newline
character(s) to the output.
.ie n .SS "$string format_number($number,$options)"
.el .SS "\f(CW$string\fP format_number($number,$options)"
.IX Subsection "$string format_number($number,$options)"
This method implements the numbers-specific formatting, by calling into
Locale::MakePhrase::Numeric's \f(CW\*(C`stringify_number\*(C'\fR method.
.PP
To provide custom handling of number formatting, you can do one of:
.IP "\(bu" 2
Define a Locale::MakePhrase::Numeric number formatting option.
.IP "\(bu" 2
Implement 'per\-language' number formatting, by sub-classing the
Locale::MakePhrase::Language module, then implementing a
\&\f(CW\*(C`format_number\*(C'\fR method.
.ie n .SS "$backing_store \fIfallback_backing_store()\fP"
.el .SS "\f(CW$backing_store\fP \fIfallback_backing_store()\fP"
.IX Subsection "$backing_store fallback_backing_store()"
Backing store to use, if not specified on construction.  You can
overload this in a sub-class.
.ie n .SS "$string \fIfallback_language()\fP"
.el .SS "\f(CW$string\fP \fIfallback_language()\fP"
.IX Subsection "$string fallback_language()"
Language to fallback to, if all others fail (this defaults to '\fBen\fR').
You can override this method in a sub-class.
.PP
Usually this will be the language that you are writing your application
code (eg: you may be coding using German rather than English).
.PP
Note that this must return a \s-1RFC\-3066\s0 compliant language tag.
.ie n .SS "$string_array \fIlanguage_classes()\fP"
.el .SS "\f(CW$string_array\fP \fIlanguage_classes()\fP"
.IX Subsection "$string_array language_classes()"
This method returns a list of possible class names (which must be
sub-classes of Locale::MakePhrase::Language) which can get
prepended to the language tags for this instance.  Locale::MakePhrase
will then try to dynamically load these modules during construction.
.PP
The idea being that you simply need to put your language-specific
module in the same directory as your sub-class, thus we will find the
custom modules.
.PP
Alternatively, you can sub-class this method, to return the correct
class heirachy name.
.ie n .SS "$format numeric_format($format)"
.el .SS "\f(CW$format\fP numeric_format($format)"
.IX Subsection "$format numeric_format($format)"
This method allows you to set and/or get the format that is being used
for numeric formatting.  You can supply an array, an array ref, or a string.
.SS "Accessor methods"
.IX Subsection "Accessor methods"
.ie n .IP "$hash \fB\f(BIoptions()\fB\fR" 2
.el .IP "\f(CW$hash\fR \fB\f(BIoptions()\fB\fR" 2
.IX Item "$hash options()"
Returns the options that were supplied to the constructor.
.ie n .IP "$string_array \fB\f(BIlanguages()\fB\fR" 2
.el .IP "\f(CW$string_array\fR \fB\f(BIlanguages()\fB\fR" 2
.IX Item "$string_array languages()"
Returns a list of the language tags that are in use.
.ie n .IP "$object_list \fB\f(BIlanguage_modules()\fB\fR" 2
.el .IP "\f(CW$object_list\fR \fB\f(BIlanguage_modules()\fB\fR" 2
.IX Item "$object_list language_modules()"
Returns a list of the loaded language modules.
.ie n .IP "$object \fB\f(BIbacking_store()\fB\fR" 2
.el .IP "\f(CW$object\fR \fB\f(BIbacking_store()\fB\fR" 2
.IX Item "$object backing_store()"
Returns the loaded backing store instance.
.ie n .IP "$object \fB\f(BIrule_manager()\fB\fR" 2
.el .IP "\f(CW$object\fR \fB\f(BIrule_manager()\fB\fR" 2
.IX Item "$object rule_manager()"
Returns the loaded rule manager instance.
.ie n .IP "$string \fB\f(BIencoding()\fB\fR" 2
.el .IP "\f(CW$string\fR \fB\f(BIencoding()\fB\fR" 2
.IX Item "$string encoding()"
Returns the output character set encoding.
.ie n .IP "$int \fB\f(BImalformed_character_mode()\fB\fR" 2
.el .IP "\f(CW$int\fR \fB\f(BImalformed_character_mode()\fB\fR" 2
.IX Item "$int malformed_character_mode()"
Returns the current \s-1UTF\-8\s0 malformed character output mode.
.ie n .IP "$bool \fB\f(BIdie_on_bad_translation()\fB\fR" 2
.el .IP "\f(CW$bool\fR \fB\f(BIdie_on_bad_translation()\fB\fR" 2
.IX Item "$bool die_on_bad_translation()"
Returns the current state of 'die_on_bad_translation'.
.ie n .IP "$bool \fB\f(BItranslate_arguments()\fB\fR" 2
.el .IP "\f(CW$bool\fR \fB\f(BItranslate_arguments()\fB\fR" 2
.IX Item "$bool translate_arguments()"
Returns the current state of 'translate_arguments'.
.ie n .IP "$bool \fB\f(BIadd_newline()\fB\fR" 2
.el .IP "\f(CW$bool\fR \fB\f(BIadd_newline()\fB\fR" 2
.IX Item "$bool add_newline()"
Returns the current state of 'add_newline'.
.ie n .IP "$bool \fB\f(BIpanic_language_lookup()\fB\fR" 2
.el .IP "\f(CW$bool\fR \fB\f(BIpanic_language_lookup()\fB\fR" 2
.IX Item "$bool panic_language_lookup()"
Returns the current state of 'panic_language_lookup'.
.SH "Function API"
.IX Header "Function API"
The following items are helper functions, which can be used to
simplify the usage of Locale::MakePhrase objects.
.ie n .SS "$string mp($string [, ...])"
.el .SS "\f(CW$string\fP mp($string [, ...])"
.IX Subsection "$string mp($string [, ...])"
This is a helper function to the \fItranslate()\fR function call.  It will
use the last-constructed instance of Locale::MakePhrase to invoke
the translate function on. eg:
.PP
.Vb 1
\&  print mp("This is test no: [_1]",$test_no);
.Ve
.PP
could produce:
.PP
.Vb 1
\&  This is the first test.
.Ve
.ie n .SS "$string _\|_ $string [, ...]"
.el .SS "\f(CW$string\fP _\|_ \f(CW$string\fP [, ...]"
.IX Subsection "$string __ $string [, ...]"
This function is the same as the previous helper function, except that
it makes you code easier to read and easier to write. eg:
.PP
.Vb 1
\&  print _\|_"This is test no: [_1]",$test_no;
.Ve
.PP
could produce:
.PP
.Vb 1
\&  This is test no: 4
.Ve
.PP
Note that we use double-underscore as this makes search-n-replace tasks
easier than if we used a single-underscore.
.SS "\s-1NOTE\s0"
.IX Subsection "NOTE"
The previous functions use a reference to an internal variable.  If
you are using this module from within Apache (say under mod_perl),
make sure that you construct a new instance of a Locale::MakePhrase
object, in the child Apache processes.
.SH "SUB-CLASSING"
.IX Header "SUB-CLASSING"
These modules can be used standalone, or they can be sub-classed so as
to control certain aspects of its behaviour.  Each inidividual module
from this group, is capable of being sub-classed; refer to each
modules' specific documentation, for more details.
.PP
In particular the Locale::MakePhrase::Language module is designed
to be sub-classed, so as to support, say, language-specific keyboard
input handling.
.SS "Construction control"
.IX Subsection "Construction control"
Due to the magic of inheritance, there are two primary ways to
control construction any of these modules:
.IP "1." 3
Overload the \f(CW\*(C`new()\*(C'\fR method
.RS 3
.IP "\(bu" 2
Implement the \f(CW\*(C`new()\*(C'\fR method in your sub-class
.IP "\(bu" 2
call \f(CW\*(C`SUPER::new()\*(C'\fR so as to execute the parent class constructor
.IP "\(bu" 2
re-bless the returned object
.RE
.RS 3
.Sp
For example:
.Sp
.Vb 8
\&  sub new {
\&    my $class = shift;
\&    ...
\&    my $self = $class\->SUPER::new(...sub\-class specific arguments...);
\&    $self = bless $self, $class;
\&    ...
\&    return $self;
\&  }
.Ve
.RE
.IP "2." 3
Overload the \f(CW\*(C`init()\*(C'\fR method.
.RS 3
.IP "\(bu" 2
implement the \f(CW\*(C`init()\*(C'\fR method in your sub-class
.IP "\(bu" 2
return a reference to the current object.
.RE
.RS 3
.Sp
For example:
.Sp
.Vb 5
\&  sub init {
\&    my $self = shift;
\&    ...
\&    return $self;
\&  }
.Ve
.RE
.SS "Sub-classing this module"
.IX Subsection "Sub-classing this module"
This module (\f(CW\*(C`Makephrase.pm\*(C'\fR) has a number of methods which can be
overloaded:
.IP "\(bu" 2
\&\fIinit()\fR
.IP "\(bu" 2
\&\fIfallback_backing_store()\fR
.IP "\(bu" 2
\&\fIfallback_language()\fR
.IP "\(bu" 2
\&\fIlanguage_classes()\fR
.IP "\(bu" 2
\&\fIformat_number()\fR
.SH "DEBUGGING"
.IX Header "DEBUGGING"
Since this module and framework are relativley new, it is quite likely
that a few bugs may still exist.  By setting the module-specific
\&\f(CW\*(C`DEBUG\*(C'\fR variable, you can enable debug messages to be sent to \s-1STDERR\s0.
.PP
Set the value to zero, to disable debug.  Setting progressively higher
values (up to a maximum value of 9), results in more debug messages
being generated.
.PP
The following variables can be set:
.PP
.Vb 7
\&  $Locale::MakePhrase::DEBUG
\&  $Locale::MakePhrase::RuleManager::DEBUG
\&  $Locale::MakePhrase::LanguageRule::DEBUG
\&  $Locale::MakePhrase::BackingStore::Cached::DEBUG
\&  $Locale::MakePhrase::BackingStore::File::DEBUG
\&  $Locale::MakePhrase::BackingStore::Directory::DEBUG
\&  $Locale::MakePhrase::BackingStore::PostgreSQL::DEBUG
.Ve
.SH "NOTES"
.IX Header "NOTES"
.SS "Text directionality"
.IX Subsection "Text directionality"
This module internally uses \s-1UTF\-8\s0 character encoding for text storage
for a number of reasons, one of them being for the ability to encode
the directionality within the text string using Unicode character
glyphs.
.PP
However it is up to the application drawing mechanism to support the
correct interpretation of these Unicode glyphs, before the text can be
displayed in the correct direction.
.SS "Localised text layout"
.IX Subsection "Localised text layout"
In some languages there may be a requirement that we layout the
application interface, using a different layout scheme than what would
normally be available.  This requirement is known as layout
localisation.  An example might be, Chinese text should prefer to
layout top-to-bottom left-to-right, (rather than left-to-right
top-to-bottom).
.PP
This module doesn't provide this facility, as that is up to the
application layout mechanism to handle the differences in layout.  eg:
A web-browser uses \s-1HTML\s0 as a formatting language; web-browsers do not
implement top-to-bottom text layout.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Locale::MakePhrase is made up of a number of modules, for which
there is \s-1POD\s0 documentation for each module. Refer to:
.IP ".  Locale::MakePhrase::Language" 2
.IX Item ".  Locale::MakePhrase::Language"
.PD 0
.IP ".  Locale::MakePhrase::Language::en" 2
.IX Item ".  Locale::MakePhrase::Language::en"
.IP ".  Locale::MakePhrase::LanguageRule" 2
.IX Item ".  Locale::MakePhrase::LanguageRule"
.IP ".  Locale::MakePhrase::RuleManager" 2
.IX Item ".  Locale::MakePhrase::RuleManager"
.IP ".  Locale::MakePhrase::BackingStore" 2
.IX Item ".  Locale::MakePhrase::BackingStore"
.IP ".  Locale::MakePhrase::BackingStore::File" 2
.IX Item ".  Locale::MakePhrase::BackingStore::File"
.IP ".  Locale::MakePhrase::BackingStore::Directory" 2
.IX Item ".  Locale::MakePhrase::BackingStore::Directory"
.IP ".  Locale::MakePhrase::BackingStore::PostgreSQL" 2
.IX Item ".  Locale::MakePhrase::BackingStore::PostgreSQL"
.IP ".  Locale::MakePhrase::Utils" 2
.IX Item ".  Locale::MakePhrase::Utils"
.IP ".  Locale::MakePhrase::Numeric" 2
.IX Item ".  Locale::MakePhrase::Numeric"
.IP ".  Locale::MakePhrase::Print" 2
.IX Item ".  Locale::MakePhrase::Print"
.PD
.PP
It also uses the following modules internally:
.IP ".  Encode" 2
.IX Item ".  Encode"
.PD 0
.IP ".  Encode::Alias" 2
.IX Item ".  Encode::Alias"
.IP ".  I18N::LangTags" 2
.IX Item ".  I18N::LangTags"
.PD
.PP
You can (and should) read the documentation provided by the
Locale::Maketext module.
.SH "BUGS"
.IX Header "BUGS"
.SS "Multiple levels of quoting"
.IX Subsection "Multiple levels of quoting"
The rule expression parser cannot handle multiple levels of quoting.
It needs modification to support this (however, this may make the
parser slower).
.SS "Expression parsing failure"
.IX Subsection "Expression parsing failure"
The rule expression parser splits the rule into sub-expressions by
chunking on ' && '.  This means it will fail to parse a text
evaluation containing these characters. For example this will fail to
parse:
.PP
.Vb 1
\&  _1 eq \*(Aq && \*(Aq
.Ve
.PP
Since the ' && ' is not a common text expression, this bug will
probably never be fixed.
.SH "TODO"
.IX Header "TODO"
Need to add support for male / female context of phrase.  This could
be implemented using a context specific translation, however the
better way would be to add native support for gender.
.SH "CREDITES"
.IX Header "CREDITES"
This module was written for NetRatings, Inc.; they paid for part of
my time to develop this module.
.PP
Various suggestions and bug fixes were also provided by:
.IP "Brendon Oliver" 4
.IX Item "Brendon Oliver"
.PD 0
.IP "John Griffin" 4
.IX Item "John Griffin"
.PD
.SH "LICENSE"
.IX Header "LICENSE"
This module was written by Mathew Robertson <mailto:mathew@users.sf.net>
for NetRatings, Inc. http://www.netratings.com.  Copyright (C) 2006
.PP
This module is free software; you can redistribute it and/or modify it
under the terms of the \s-1GNU\s0 Lesser General Public License version 2 (or
at your option, any later version) as published by the Free Software
Foundation http://www.fsf.org.
.PP
This module is distributed \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0 \s-1WHATSOEVER\s0, in the
hope that it will be useful to others.
.SH "POD ERRORS"
.IX Header "POD ERRORS"
Hey! \fBThe above document had some coding errors, which are explained below:\fR
.IP "Around line 1077:" 4
.IX Item "Around line 1077:"
=cut found outside a pod block.  Skipping to next block.

Copyright 2K16 - 2K18 Indonesian Hacker Rulez