<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP — Translate Toolkit 1.9.0 documentation</title> <link rel="stylesheet" href="../_static/basic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="../_static/bootstrap.css" type="text/css" /> <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.9.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/bootstrap.js"></script> <script type="text/javascript" src="../_static/bootstrap-sphinx.js"></script> <link rel="top" title="Translate Toolkit 1.9.0 documentation" href="../index.html" /> <link rel="up" title="Translation Related File Formats" href="index.html" /> <link rel="next" title="Qt .ts" href="ts.html" /> <link rel="prev" title="OpenOffice.org GSI/SDF format" href="gsi.html" /> </head> <body> <div id="navbar" class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="container-fluid"> <a class="brand" href="../index.html">Translate Toolkit</a> <span class="navbar-text pull-left"><b>1.9.0</b></span> <ul class="nav"> <li class="divider-vertical"></li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Site <b class="caret"></b></a> <ul class="dropdown-menu globaltoc"><ul class="simple"> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="../features.html">Features</a></li> <li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a></li> <li class="toctree-l1"><a class="reference internal" href="../commands/index.html">Converters</a></li> <li class="toctree-l1"><a class="reference internal" href="../commands/index.html#tools">Tools</a></li> <li class="toctree-l1"><a class="reference internal" href="../commands/index.html#scripts">Scripts</a></li> <li class="toctree-l1"><a class="reference internal" href="../guides/index.html">Use Cases</a></li> <li class="toctree-l1"><a class="reference internal" href="index.html">Supported formats</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="../styleguide.html">Translate Styleguide</a></li> <li class="toctree-l1"><a class="reference internal" href="../styleguide.html#documentation">Documentation</a></li> <li class="toctree-l1"><a class="reference internal" href="../development/building.html">Building</a></li> <li class="toctree-l1"><a class="reference internal" href="../development/contributing.html">Contributing</a></li> <li class="toctree-l1"><a class="reference internal" href="../development/developers.html">Translate Toolkit Developers Guide</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="../api/index.html">API</a></li> </ul> <ul> <li class="toctree-l1"><a class="reference internal" href="../changelog.html">Important Changes</a></li> <li class="toctree-l1"><a class="reference internal" href="../history.html">History of the Translate Toolkit</a></li> <li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li> </ul> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Page <b class="caret"></b></a> <ul class="dropdown-menu localtoc"><ul> <li><a class="reference internal" href="#">PHP</a><ul> <li><a class="reference internal" href="#example">Example</a></li> <li><a class="reference internal" href="#conformance">Conformance</a></li> <li><a class="reference internal" href="#non-conformance">Non-Conformance</a></li> </ul> </li> </ul> </ul> </li> <li><a href="gsi.html" title="previous chapter">« OpenOffice.org GSI/SDF format</a></li> <li><a href="ts.html" title="next chapter">Qt .ts »</a></li> </ul> <form class="navbar-search pull-right" action="../search.html" method="get"> <input type="text" name="q" placeholder="Search" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </ul> </div> </div> </div> </div> <div class="container content"> <div class="section" id="php"> <span id="id1"></span><h1>PHP<a class="headerlink" href="#php" title="Permalink to this headline">¶</a></h1> <p>Many <a class="reference external" href="https://en.wikipedia.org/wiki/PHP">PHP</a> programs make use of a localisable string array. The toolkit supports the full localisation of such files with <a class="reference internal" href="../commands/php2po.html"><em>php2po</em></a> and po2php.</p> <div class="section" id="example"> <span id="php-example"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> <p>The localisable string arrays appear like this:</p> <div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span> <span class="nv">$string</span><span class="p">[</span><span class="s1">'name'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'value'</span> </pre></div> </div> </div> <div class="section" id="conformance"> <span id="php-conformance"></span><h2>Conformance<a class="headerlink" href="#conformance" title="Permalink to this headline">¶</a></h2> <p>Our format support allows:</p> <ul class="simple"> <li>PHP escaping (both for <a class="reference external" href="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single">single</a> and <a class="reference external" href="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double">double</a> quoted strings)</li> <li>Multiline entries</li> <li>PHP simple variable syntax</li> </ul> <div class="highlight-php"><div class="highlight"><pre><span class="x">$variable = 'string';</span> <span class="x">$another_variable = "another string";</span> </pre></div> </div> <ul> <li><p class="first">Various layouts of the id</p> <div class="highlight-php"><div class="highlight"><pre><span class="x">$string['name'];</span> <span class="x">$string['name'] ;</span> <span class="x">$string[name];</span> <span class="x">$string[ 'name' ];</span> </pre></div> </div> </li> <li><p class="first">PHP array syntax for localisation (since > 1.6.0)</p> <div class="highlight-php"><div class="highlight"><pre><span class="x">$lang = array(</span> <span class="x"> 'name' => 'value',</span> <span class="x"> 'name2' => 'value2',</span> <span class="x">);</span> </pre></div> </div> </li> <li><p class="first">PHP define syntax</p> </li> </ul> <div class="highlight-php"><div class="highlight"><pre><span class="x">define('item', 'string');</span> <span class="x">define("another_item", "another string");</span> </pre></div> </div> <ul> <li><p class="first">Whitespace before end delimiter</p> <div class="highlight-php"><div class="highlight"><pre><span class="x">$string['name'] ;</span> <span class="x">$string['name'] ;</span> </pre></div> </div> </li> </ul> </div> <div class="section" id="non-conformance"> <span id="php-non-conformance"></span><h2>Non-Conformance<a class="headerlink" href="#non-conformance" title="Permalink to this headline">¶</a></h2> <p>The following are not yet supported:</p> <ul class="simple"> <li><a class="reference external" href="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc">herdoc</a> and <a class="reference external" href="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc">nowdoc</a> are not managed</li> </ul> </div> </div> </div> <hr> <footer class="footer"> <div class="container"> <p class="pull-right"><a href="#">Back to top ↑</a></p> <ul class="unstyled muted"> <li><small> © 2012, Translate.org.za.<br/> </small></li> <li><small> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </small></li> </ul> </div> </footer> </body> </html>