<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.gettext.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.gettext.php',
    1 => 'gettext',
    2 => 'Lookup a message in the current domain',
  ),
  'up' => 
  array (
    0 => 'ref.gettext.php',
    1 => 'Gettext Functions',
  ),
  'prev' => 
  array (
    0 => 'function.dngettext.php',
    1 => 'dngettext',
  ),
  'next' => 
  array (
    0 => 'function.ngettext.php',
    1 => 'ngettext',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/gettext/functions/gettext.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.gettext" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gettext</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gettext</span> &mdash; <span class="dc-title">Lookup a message in the current domain</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.gettext-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gettext</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$message</code></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Looks up a message in the current domain.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gettext-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">message</code></dt>
     <dd>
      <p class="para">
       The message being translated.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gettext-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a translated <span class="type"><a href="language.types.string.php" class="type string">string</a></span> if one is found in the 
   translation table, or the submitted message if not found.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.gettext-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>gettext()</strong></span>-check</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Set language to German<br /></span><span style="color: #0000BB">putenv</span><span style="color: #007700">(</span><span style="color: #DD0000">'LC_ALL=de_DE'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">, </span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Specify location of translation tables<br /></span><span style="color: #0000BB">bindtextdomain</span><span style="color: #007700">(</span><span style="color: #DD0000">"myPHPApp"</span><span style="color: #007700">, </span><span style="color: #DD0000">"./locale"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Choose domain<br /></span><span style="color: #0000BB">textdomain</span><span style="color: #007700">(</span><span style="color: #DD0000">"myPHPApp"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Translation is looking for in ./locale/de_DE/LC_MESSAGES/myPHPApp.mo now<br /><br />// Print a test message<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">gettext</span><span style="color: #007700">(</span><span style="color: #DD0000">"Welcome to My PHP Application"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Or use the alias _() for gettext()<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">_</span><span style="color: #007700">(</span><span style="color: #DD0000">"Have a nice day"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>
 

 <div class="refsect1 notes" id="refsect1-function.gettext-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    You may use the underscore character &#039;_&#039; as an alias to this function.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Setting a language isn&#039;t enough for some systems and the 
    <span class="function"><a href="function.putenv.php" class="function">putenv()</a></span> should be used to define the 
    current locale.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gettext-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.-.php" class="function" rel="rdfs-seeAlso">_()</a> - Alias of gettext</span></li>
    <li><span class="function"><a href="function.setlocale.php" class="function" rel="rdfs-seeAlso">setlocale()</a> - Set locale information</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>