Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 905

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The MessageFormatter class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="normalizer.normalize.html">Normalizer::normalize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="messageformatter.create.html">MessageFormatter::create</a></div>
 <div class="up"><a href="book.intl.html">intl</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.messageformatter" class="reference">
 <h1 class="title">The MessageFormatter class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p>

  
  <div class="section" id="messageformatter.intro">
   <h2 class="title">Introduction</h2>
   <p class="simpara">
    MessageFormatter is a concrete class that enables users to produce
    concatenated, language-neutral messages. The methods supplied in this
    class are used to build all the messages that are seen by end users.
   </p>
   <p class="simpara">
    The MessageFormatter class assembles messages from various fragments (such
    as text fragments, numbers, and dates) supplied by the program. Because of
    the MessageFormatter class, the program does not need to know the order of
    the fragments. The class uses the formatting specifications for the
    fragments to assemble them into a message that is contained in a single
    string within a resource bundle. For example, MessageFormatter enables you
    to print the phrase &quot;Finished printing x out of y files...&quot; in a manner
    that still allows for flexibility in translation.
   </p>
   <p class="simpara">
    Previously, an end user message was created as a sentence and handled as a
    string. This procedure created problems for localizers because the
    sentence structure, word order, number format and so on are very different
    from language to language. The language-neutral way to create messages
    keeps each part of the message separate and provides keys to the data.
    Using these keys, the MessageFormatter class can concatenate the parts of
    the message, localize them, and display a well-formed string to the end
    user.
   </p>
   <p class="simpara">
    MessageFormatter takes a set of objects, formats them, and then inserts
    the formatted strings into the pattern at the appropriate places. Choice
    formats can be used in conjunction with MessageFormatter to handle
    plurals, match numbers, and select from an array of items. Typically, the
    message format will come from resources and the arguments will be
    dynamically set at runtime.
   </p>
  </div>
  

  <div class="section" id="messageformatter.synopsis">
   <h2 class="title">Class synopsis</h2>

   
   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    
    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">MessageFormatter</strong>
     </span>
     {</div>
    

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>
    <span class="methodname"><a href="messageformatter.create.html" class="methodname">__construct</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>
   )</div>

    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">MessageFormatter</span>
    <span class="methodname"><a href="messageformatter.create.html" class="methodname">create</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">string</span>
    <span class="methodname"><a href="messageformatter.formatmessage.html" class="methodname">formatMessage</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span>
    <span class="methodname"><a href="messageformatter.format.html" class="methodname">format</a></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">int</span>
    <span class="methodname"><a href="messageformatter.geterrorcode.html" class="methodname">getErrorCode</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span>
    <span class="methodname"><a href="messageformatter.geterrormessage.html" class="methodname">getErrorMessage</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span>
    <span class="methodname"><a href="messageformatter.getlocale.html" class="methodname">getLocale</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span>
    <span class="methodname"><a href="messageformatter.getpattern.html" class="methodname">getPattern</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="type">array</span>
    <span class="methodname"><a href="messageformatter.parsemessage.html" class="methodname">parseMessage</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$source</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">array</span>
    <span class="methodname"><a href="messageformatter.parse.html" class="methodname">parse</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$value</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span>
    <span class="methodname"><a href="messageformatter.setpattern.html" class="methodname">setPattern</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>
   )</div>

   }</div>
   

  </div>

  <div class="section" id="messageformatter.seealso">
   <h2 class="title">See Also</h2>
   <p class="para">
    <ul class="simplelist">
     <li class="member">
      <a href="http://icu-project.org/userguide/formatParse.html" class="link external">&raquo;&nbsp;
       ICU formatting documentation
      </a>
     </li>
     <li class="member">
      <a href="http://icu-project.org/userguide/formatMessages.html" class="link external">&raquo;&nbsp;
       ICU message formatting description
      </a>
     </li>
     <li class="member">
      <a href="http://icu-project.org/apiref/icu4c/classMessageFormat.html#details" class="link external">&raquo;&nbsp;ICU message formatters</a>
     </li>
     <li class="member">
      <a href="http://icu-project.org/apiref/icu4c/classChoiceFormat.html#details" class="link external">&raquo;&nbsp;ICU choice formatters</a>
     </li>
    </ul>
   </p>
  </div>
 </div>

 



















































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="messageformatter.create.html">MessageFormatter::create</a> — Constructs a new Message Formatter</li><li><a href="messageformatter.formatmessage.html">MessageFormatter::formatMessage</a> — Quick format message</li><li><a href="messageformatter.format.html">MessageFormatter::format</a> — Format the message</li><li><a href="messageformatter.geterrorcode.html">MessageFormatter::getErrorCode</a> — Get the error code from last operation</li><li><a href="messageformatter.geterrormessage.html">MessageFormatter::getErrorMessage</a> — Get the error text from the last operation</li><li><a href="messageformatter.getlocale.html">MessageFormatter::getLocale</a> — Get the locale for which the formatter was created.</li><li><a href="messageformatter.getpattern.html">MessageFormatter::getPattern</a> — Get the pattern used by the formatter</li><li><a href="messageformatter.parsemessage.html">MessageFormatter::parseMessage</a> — Quick parse input string</li><li><a href="messageformatter.parse.html">MessageFormatter::parse</a> — Parse input string according to pattern</li><li><a href="messageformatter.setpattern.html">MessageFormatter::setPattern</a> — Set the pattern used by the formatter</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="normalizer.normalize.html">Normalizer::normalize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="messageformatter.create.html">MessageFormatter::create</a></div>
 <div class="up"><a href="book.intl.html">intl</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>