Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f9d20baf2d42bbb9f9c5746dba0abad5 > files > 206

python-translate-doc-1.10.0-3.mga4.noarch.rpm


<!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>php2po &mdash; 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="Converters" href="index.html" />
    <link rel="next" title="sub2po" href="sub2po.html" />
    <link rel="prev" title="prop2po" href="prop2po.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="index.html">Converters</a></li>
<li class="toctree-l1"><a class="reference internal" href="index.html#tools">Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="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="../formats/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="#">php2po</a><ul>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#formats-supported">Formats Supported</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
</ul>
</ul>
</li>
            
            
              
  <li><a href="prop2po.html"
         title="previous chapter">&laquo; prop2po</a></li>
  <li><a href="sub2po.html"
         title="next chapter">sub2po &raquo;</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="po2php">
<span id="php2po"></span><span id="id1"></span><h1>php2po<a class="headerlink" href="#po2php" title="Permalink to this headline">¶</a></h1>
<p>Converts PHP localisable string arrays to Gettext PO format.</p>
<div class="section" id="usage">
<span id="php2po-usage"></span><h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><pre>php2po [options] &lt;php&gt; &lt;po&gt;
po2php [options] &lt;po&gt; &lt;php&gt;</pre>
</div>
<p>Where:</p>
<table border="1" class="docutils">
<colgroup>
<col width="11%" />
<col width="89%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>&lt;php&gt;</td>
<td>is a valid PHP localisable file or directory of those files</td>
</tr>
<tr class="row-even"><td>&lt;po&gt;</td>
<td>is a directory of PO or POT files</td>
</tr>
</tbody>
</table>
<p>Options (php2po):</p>
<table class="docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">--version</span></kbd></td>
<td>show program&#8217;s version number and exit</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></td>
<td>show this help message and exit</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--manpage</span></kbd></td>
<td>output a manpage based on the help</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--progress=<var>PROGRESS</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>show progress as: <a class="reference internal" href="option_progress.html"><em>dots, none, bar, names, verbose</em></a></td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--errorlevel=<var>ERRORLEVEL</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>show errorlevel as: <a class="reference internal" href="option_errorlevel.html"><em>none, message, exception,
traceback</em></a></td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-i <var>INPUT</var></span>, <span class="option">--input=<var>INPUT</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>read from INPUT in php format</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-x <var>EXCLUDE</var></span>, <span class="option">--exclude=<var>EXCLUDE</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>exclude names matching EXCLUDE from input paths</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-o <var>OUTPUT</var></span>, <span class="option">--output=<var>OUTPUT</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>write to OUTPUT in po, pot formats</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-t <var>TEMPLATE</var></span>, <span class="option">--template=<var>TEMPLATE</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>read from TEMPLATE in php format</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--psyco=<var>MODE</var></span></kbd></td>
<td>use psyco to speed up the operation, modes: <a class="reference internal" href="option_psyco.html"><em>none,
full, profile</em></a></td></tr>
<tr><td class="option-group">
<kbd><span class="option">-P</span>, <span class="option">--pot</span></kbd></td>
<td>output PO Templates (.pot) rather than PO files (.po)</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--duplicates=<var>DUPLICATESTYLE</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>what to do with duplicate strings (identical source
text): <a class="reference internal" href="option_duplicates.html"><em>merge, msgctxt</em></a>
(default: &#8216;msgctxt&#8217;)</td></tr>
</tbody>
</table>
<p>Options (po2php):</p>
<table class="docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">--version</span></kbd></td>
<td>show program&#8217;s version number and exit</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></td>
<td>show this help message and exit</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--manpage</span></kbd></td>
<td>output a manpage based on the help</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--progress=<var>PROGRESS</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>show progress as: <a class="reference internal" href="option_progress.html"><em>dots, none, bar, names, verbose</em></a></td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--errorlevel=<var>ERRORLEVEL</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>show errorlevel as: <a class="reference internal" href="option_errorlevel.html"><em>none, message, exception,
traceback</em></a></td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-i <var>INPUT</var></span>, <span class="option">--input=<var>INPUT</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>read from INPUT in po, pot formats</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-x <var>EXCLUDE</var></span>, <span class="option">--exclude=<var>EXCLUDE</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>exclude names matching EXCLUDE from input paths</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-o <var>OUTPUT</var></span>, <span class="option">--output=<var>OUTPUT</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>write to OUTPUT in php format</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-t <var>TEMPLATE</var></span>, <span class="option">--template=<var>TEMPLATE</var></span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>read from TEMPLATE in php format</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--psyco=<var>MODE</var></span></kbd></td>
<td>use psyco to speed up the operation, modes: <a class="reference internal" href="option_psyco.html"><em>none,
full, profile</em></a></td></tr>
<tr><td class="option-group">
<kbd><span class="option">--fuzzy</span></kbd></td>
<td>use translations marked fuzzy</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--nofuzzy</span></kbd></td>
<td>don&#8217;t use translations marked fuzzy (default)</td></tr>
</tbody>
</table>
</div>
<div class="section" id="formats-supported">
<span id="php2po-formats-supported"></span><h2>Formats Supported<a class="headerlink" href="#formats-supported" title="Permalink to this headline">¶</a></h2>
<p>PHP files need to be organized into separate languages per file and in the
following format:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="x">$variable = &#39;string&#39;;</span>
<span class="x">$another_variable = &quot;another string&quot;;</span>
</pre></div>
</div>
<p>If $variable is an array it can be declared with the square bracket syntax:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="x">$lang[&#39;item&#39;] = &#39;string&#39;;</span>
<span class="x">$lang[&#39;another_item&#39;] = &quot;another string&quot;;</span>
</pre></div>
</div>
<p>The converter also supports arrays in the form:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="x">$variable = array(</span>
<span class="x">   name =&gt; &#39;value&#39;,</span>
<span class="x">   other =&gt; &quot;other value&quot;,</span>
<span class="x">)</span>
</pre></div>
</div>
<p>Finally, the converter also supports the define syntax:</p>
<div class="highlight-php"><div class="highlight"><pre><span class="x">define(&#39;item&#39;, &#39;string&#39;);</span>
<span class="x">define(&quot;another_item&quot;, &quot;another string&quot;);</span>
</pre></div>
</div>
<p>Gettext notations are also not supported, use the Gettext tools for those
files.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Nested arrays are not supported:</p>
</div>
<div class="highlight-php"><div class="highlight"><pre><span class="x">$lang = array(array(&#39;key&#39; =&gt; &#39;value&#39;)); #NOT SUPPORTED</span>
</pre></div>
</div>
</div>
<div class="section" id="examples">
<span id="php2po-examples"></span><h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<p>This example looks at roundtrip of PHP translations as well as recovery of
existing translations.</p>
<p>First we need to create a set of POT files.:</p>
<div class="highlight-python"><pre>php2po -P lang/en pot/</pre>
</div>
<p>All .php files found in the <tt class="docutils literal"><span class="pre">lang/en</span></tt> directory are converted to Gettext POT
files and placed in the <tt class="docutils literal"><span class="pre">pot</span></tt> directory.</p>
<p>If you are translating for the first time then you can skip the next step. If
you need to recover your existing translations then we do the following:</p>
<div class="highlight-python"><pre>php2po -t lang/en lang/zu po-zu/</pre>
</div>
<p>Using the English PHP files found in <tt class="docutils literal"><span class="pre">lang/en</span></tt> and your existing Zulu
translation in <tt class="docutils literal"><span class="pre">lang/zu</span></tt> we create a set of PO files in <tt class="docutils literal"><span class="pre">po-zu</span></tt>.  These
will now have your translations. Please be aware that in order for that to work
100% you need to have both English and Zulu at the same revision, if they are
not you will have to review all translations.</p>
<p>You are now in a position to translate your recovered translations or your new
POT files.</p>
<p>Once translated you can convert back as follows:</p>
<div class="highlight-python"><pre>po2php -t lang/en po-zu/ lang/zu</pre>
</div>
<p>Your translations found in the Zulu PO directory, <tt class="docutils literal"><span class="pre">po-zu</span></tt>, will be converted
to PHP using the files in <tt class="docutils literal"><span class="pre">lang/en</span></tt> as templates and placing your new
translations in <tt class="docutils literal"><span class="pre">lang/zu</span></tt>.</p>
<p>To update your translations simply redo the POT creation step and make use of
<a class="reference internal" href="pot2po.html"><em>pot2po</em></a> to bring your translation up-to-date.</p>
</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>
        &copy; 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>