<!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>prop2po — 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="php2po" href="php2po.html" /> <link rel="prev" title="odf2xliff and xliff2odf" href="odf2xliff.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="#">prop2po</a><ul> <li><a class="reference internal" href="#usage">Usage</a></li> <li><a class="reference internal" href="#examples">Examples</a><ul> <li><a class="reference internal" href="#creating-pot-files">Creating POT files</a></li> <li><a class="reference internal" href="#creating-po-files-from-existing-work">Creating PO files from existing work</a></li> <li><a class="reference internal" href="#creating-properties-files-from-your-translations">Creating .properties files from your translations</a></li> </ul> </li> <li><a class="reference internal" href="#doing-away-with-native2ascii">Doing away with native2ascii</a></li> </ul> </li> </ul> </ul> </li> <li><a href="odf2xliff.html" title="previous chapter">« odf2xliff and xliff2odf</a></li> <li><a href="php2po.html" title="next chapter">php2po »</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="po2prop"> <span id="prop2po"></span><span id="id1"></span><h1>prop2po<a class="headerlink" href="#po2prop" title="Permalink to this headline">¶</a></h1> <p>Convert between Java property files (.properties) and Gettext PO format.</p> <p>Note: this tool completely eliminates the need for <a class="reference internal" href="#prop2po-doing-away-with-native2ascii"><em>native2ascii</em></a> as po2prop does the correct escaping to the Latin1 encoding that is needed by Java.</p> <p>The following other formats are also supported via the <a class="reference internal" href="option_personality.html"><em>–personality</em></a> parameter:</p> <ul class="simple"> <li>Adobe Flex</li> <li>Skype .lang</li> <li>Mac OS X .strings</li> <li>Mozilla .properties</li> </ul> <div class="section" id="usage"> <span id="prop2po-usage"></span><h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2> <div class="highlight-python"><pre>prop2po [options] <property> <po> po2prop [options] -t <template> <po> <property></pre> </div> <p>Where:</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="83%" /> </colgroup> <tbody valign="top"> <tr class="row-odd"><td><property></td> <td>is a directory containing property files or an individual property file</td> </tr> <tr class="row-even"><td><po></td> <td>is a directory containing PO files and an individual property file</td> </tr> <tr class="row-odd"><td><template></td> <td>is a directory of template property files or a single template property file</td> </tr> </tbody> </table> <p>Options (prop2po):</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’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> </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> </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> </td><td>read from INPUT in properties 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> </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> </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> </td><td>read from TEMPLATE in properties 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">--personality=<var>TYPE</var></span></kbd></td> </tr> <tr><td> </td><td>override the input file format: <a class="reference internal" href="option_personality.html"><em>flex, java, mozilla, java-utf8, skype, gaia, strings</em></a> (for .properties files, default: java)</td></tr> <tr><td class="option-group" colspan="2"> <kbd><span class="option">--encoding=<var>ENCODING</var></span></kbd></td> </tr> <tr><td> </td><td>override the encoding set by the personality</td></tr> <tr><td class="option-group" colspan="2"> <kbd><span class="option">--duplicates=<var>DUPLICATESTYLE</var></span></kbd></td> </tr> <tr><td> </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: ‘msgctxt’)</td></tr> </tbody> </table> <p>Options (po2prop):</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’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> </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> </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> </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> </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> </td><td>write to OUTPUT in properties 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> </td><td>read from TEMPLATE in properties 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" colspan="2"> <kbd><span class="option">--personality=<var>TYPE</var></span></kbd></td> </tr> <tr><td> </td><td>override the input file format: <a class="reference internal" href="option_personality.html"><em>flex, java, mozilla, java-utf8, skype, gaia, strings</em></a> (for .properties files, default: java)</td></tr> <tr><td class="option-group" colspan="2"> <kbd><span class="option">--encoding=<var>ENCODING</var></span></kbd></td> </tr> <tr><td> </td><td>override the encoding set by the personality (since 1.8.0)</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’t use translations marked fuzzy (default)</td></tr> </tbody> </table> </div> <div class="section" id="examples"> <span id="prop2po-examples"></span><h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2> <p>These examples demonstrate most of the useful invocations of prop2po:</p> <div class="section" id="creating-pot-files"> <span id="prop2po-creating-pot-files"></span><h3>Creating POT files<a class="headerlink" href="#creating-pot-files" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>prop2po -P properties pot</pre> </div> <p>Extract messages from <em>properties</em> directory and place them in a directory called <em>pot</em>. The <tt class="docutils literal"><span class="pre">-P</span></tt> option ensures that we create POT files instead of PO files.:</p> <div class="highlight-python"><pre>prop2po -P file.properties file.pot</pre> </div> <p>Extract messages from <em>file.properties</em> and place them in <em>file.pot</em>.</p> </div> <div class="section" id="creating-po-files-from-existing-work"> <span id="prop2po-creating-po-files-from-existing-work"></span><h3>Creating PO files from existing work<a class="headerlink" href="#creating-po-files-from-existing-work" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>prop2po --duplicates=msgctxt -t reference zu zu-po</pre> </div> <p>Extract all existing Zulu messages from <em>zu</em> directory and place the resultant PO files in a directory called <em>zu-po</em>. If you find duplicate messages in a file then use Gettext’s mgsctxt to disambiguate them. During the merge we use the .properties files in <em>reference</em> as templates and as the source of the English text for the msgid. Once you have your PO files you might want to use <a class="reference internal" href="pomigrate2.html"><em>pomigrate2</em></a> to ensure that your PO files match the latest POT files.</p> </div> <div class="section" id="creating-properties-files-from-your-translations"> <span id="prop2po-creating-properties-files-from-your-translations"></span><h3>Creating .properties files from your translations<a class="headerlink" href="#creating-properties-files-from-your-translations" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>po2prop -t reference zu-po zu</pre> </div> <p>Using our translations found in <em>zu-po</em> and the templates found in <em>reference</em> we create a new set of property files in <em>zu</em>. These new property files will look exactly like those found in the templates, but with the text changed to the translation. Any fuzzy entry in our PO files will be ignored and any untranslated item will be placed in <em>zu</em> in English. The .properties file created will be based on the Java specification and will thus use escaped Unicode. Where:</p> <div class="highlight-python"><pre>ṽḁḽṻḝ</pre> </div> <p>Will appear in the files as:</p> <div class="highlight-python"><pre>\u1E7D\u1E01\u1E3D\u1E7B\u1E1D</pre> </div> <p>To get output as used by Mozilla localisation do the following:</p> <div class="highlight-python"><pre>po2prop --personality=mozilla -t reference zu-po zu</pre> </div> <p>This will do exactly the same as above except that the output will now appear as real Unicode characters in UTF-8 encoding.</p> </div> </div> <div class="section" id="doing-away-with-native2ascii"> <span id="prop2po-doing-away-with-native2ascii"></span><h2>Doing away with native2ascii<a class="headerlink" href="#doing-away-with-native2ascii" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference external" href="http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/native2ascii.html">native2ascii</a> command is the traditional tool of property file localisers. With prop2po there is no need to use this command or to ever work directly with the escaped Unicode.</p> <p>If you are working mostly with Gettext PO files then this is a double benefit as you can now use your favourite PO editor to translate Java applications. Your process would now look like this:</p> <div class="highlight-python"><pre>prop2po some.properties some.po</pre> </div> <p>Firstly create a PO file that you can translate. Now translate it in your favourite PO editor.:</p> <div class="highlight-python"><pre>po2prop -t some.properties some.po some-other.properties</pre> </div> <p>Using the original properties file as a template we preserve all layout and comments, combined with your PO translation we create a new translate properties file. During this whole process we have not needed to understand or process any escaping prop2po and po2prop handle that all automatically.</p> <p>If you have existing translations you can recover them as follows:</p> <div class="highlight-python"><pre>prop2po -t some.properties translations.properties translations.po</pre> </div> <p>This takes the default English properties file and combines it with your translate properties file and created a PO file. You now continue translating using your PO file.</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> © 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>