Sophie

Sophie

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

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>Using csv2po &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="Use Cases" href="index.html" />
    <link rel="next" title="Creating OpenOffice.org POT files" href="using_oo2po.html" />
    <link rel="prev" title="Checking your files with PO filter" href="using_pofilter.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="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="#">Using csv2po</a><ul>
<li><a class="reference internal" href="#quickstart">Quickstart</a></li>
<li><a class="reference internal" href="#detailed-description">Detailed Description</a><ul>
<li><a class="reference internal" href="#creating-a-subset">Creating a subset</a></li>
<li><a class="reference internal" href="#divide-into-sections">Divide into sections</a></li>
<li><a class="reference internal" href="#creating-the-csv-files">Creating the CSV files</a></li>
<li><a class="reference internal" href="#creating-a-word-count">Creating a word count</a></li>
<li><a class="reference internal" href="#package-the-csv-files">Package the CSV files</a></li>
<li><a class="reference internal" href="#translating">Translating</a></li>
<li><a class="reference internal" href="#converting-excel-spreadsheets-to-csv-file">Converting Excel spreadsheets to CSV file</a></li>
<li><a class="reference internal" href="#converting-csv-back-to-po">Converting CSV back to PO</a></li>
<li><a class="reference internal" href="#checking-the-new-po-files">Checking the new PO files</a></li>
<li><a class="reference internal" href="#removing-fuzzies">Removing fuzzies</a></li>
<li><a class="reference internal" href="#merging-po-files-into-the-main-po-files">Merging PO files into the main PO files</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</ul>
</li>
            
            
              
  <li><a href="using_pofilter.html"
         title="previous chapter">&laquo; Checking your files with PO filter</a></li>
  <li><a href="using_oo2po.html"
         title="next chapter">Creating OpenOffice.org POT files &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="using-csv2po">
<span id="id1"></span><h1>Using csv2po<a class="headerlink" href="#using-csv2po" title="Permalink to this headline">¶</a></h1>
<p><a class="reference internal" href="../commands/csv2po.html"><em>csv2po</em></a> allows you to create CSV files from PO files.
This allows you to send translation work to translators who do not or cannot
use PO Editors but who can use a Spreadsheet.</p>
<div class="section" id="quickstart">
<span id="using-csv2po-quickstart"></span><h2>Quickstart<a class="headerlink" href="#quickstart" title="Permalink to this headline">¶</a></h2>
<ol class="arabic simple">
<li><tt class="docutils literal"><span class="pre">pofilter</span> <span class="pre">--fuzzy</span> <span class="pre">--review</span> <span class="pre">-t</span> <span class="pre">untranslated</span> <span class="pre">&lt;po-dir&gt;</span> <span class="pre">&lt;po-filtered-dir&gt;</span></tt>
(this step is optional)</li>
<li>divide into sections</li>
<li><tt class="docutils literal"><span class="pre">po2csv</span> <span class="pre">&lt;po-dir|po-filtered-dir&gt;</span> <span class="pre">&lt;csv-out&gt;</span></tt></li>
<li>edit in Excel or OpenOffice.org Calc</li>
<li><tt class="docutils literal"><span class="pre">csv2po</span> <span class="pre">--charset=windows-1250</span> <span class="pre">-t</span> <span class="pre">templates</span> <span class="pre">&lt;csv-in&gt;</span> <span class="pre">&lt;po-in&gt;</span></tt> (you must
work against a template directory, the charset option corrects problems with
characters sets)</li>
<li><tt class="docutils literal"><span class="pre">/commands/phase</span></tt> &#8211; to do basic checks sort out encoding issues</li>
<li><tt class="docutils literal"><span class="pre">pomerge</span> <span class="pre">--mergeblank=no</span> <span class="pre">-t</span> <span class="pre">&lt;po-dir&gt;</span> <span class="pre">&lt;po-in&gt;</span> <span class="pre">&lt;po-dir&gt;</span></tt></li>
<li><tt class="docutils literal"><span class="pre">git</span> <span class="pre">diff</span></tt> &#8212; check the changes</li>
<li><tt class="docutils literal"><span class="pre">git</span> <span class="pre">add</span></tt> &amp; <tt class="docutils literal"><span class="pre">git</span> <span class="pre">commit</span></tt> &#8212; commit changes</li>
</ol>
</div>
<div class="section" id="detailed-description">
<span id="using-csv2po-detailed-description"></span><h2>Detailed Description<a class="headerlink" href="#detailed-description" title="Permalink to this headline">¶</a></h2>
<p>po2csv allows you to send CSV files, which can be edited in any spreadsheet, to
a translator.  This document outlines the process to follow from the raw po
files -&gt; CSV files -&gt; back to PO.  We also look at a case where you may have
submitted a subset of the PO files for translation and you need to integrate
these.</p>
<div class="section" id="creating-a-subset">
<span id="using-csv2po-creating-a-subset"></span><h3>Creating a subset<a class="headerlink" href="#creating-a-subset" title="Permalink to this headline">¶</a></h3>
<p>This step is optional.</p>
<p>To send a translator only those messages that are untranslated, fuzzy or need
review run:</p>
<div class="highlight-python"><pre>pofilter --isfuzzy --isreview -t untranslated &lt;po-dir&gt; &lt;po-filtered-dir&gt;</pre>
</div>
</div>
<div class="section" id="divide-into-sections">
<span id="using-csv2po-divide-into-sections"></span><h3>Divide into sections<a class="headerlink" href="#divide-into-sections" title="Permalink to this headline">¶</a></h3>
<p>You might want to divide the work into sections if you are apportioning it to
different translators.  In that case create new directories:</p>
<div class="highlight-python"><pre>e.g. po-filtered-dir-1 po-filtered-dir-2
or  po-filtered-dir-bob po-filtered-dir-mary</pre>
</div>
<p>Copy files from <em>po-filtered-dir</em> to <em>po-filtered-dir-N</em> in a way that balance
the work or apportions the amounts you want for each translator.  Try to keep
sections together and not break them up to much e.g.  Give one translator all
the OpenOffice.org Calc work don&#8217;t split it between two people &#8211; this is just a
simple measure to ensure constancy.</p>
<p>Now continue as normal and convert to CSV and perform word counts for each
separate directory.</p>
</div>
<div class="section" id="creating-the-csv-files">
<span id="using-csv2po-creating-the-csv-files"></span><h3>Creating the CSV files<a class="headerlink" href="#creating-the-csv-files" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><pre>po2csv &lt;po-dir|po-filtered-dir&gt; &lt;csv-out&gt;</pre>
</div>
<p>This will create a set of CSV files in <em>csv-out</em> which you can compress using
zip (we use zip because most people are Windows users)</p>
</div>
<div class="section" id="creating-a-word-count">
<span id="using-csv2po-creating-a-word-count"></span><h3>Creating a word count<a class="headerlink" href="#creating-a-word-count" title="Permalink to this headline">¶</a></h3>
<p>Professional translators work on source word counts.  So we create a word count
to go with the file:</p>
<div class="highlight-python"><pre>pocount `find po-dir|po-filtered-dir -name "*.po"`</pre>
</div>
<p>We work on source words regardless of whether the string is fuzzy or not.  You
might want to get a lower rate for work on fuzzy strings.</p>
<p>Place the word count file in both the PO and CSV directory to avoid the problem
of finding it later.  Check the number to make sure you haven&#8217;t inadvertently
including something that you didn&#8217;t want in.</p>
</div>
<div class="section" id="package-the-csv-files">
<span id="using-csv2po-package-the-csv-files"></span><h3>Package the CSV files<a class="headerlink" href="#package-the-csv-files" title="Permalink to this headline">¶</a></h3>
<div class="highlight-python"><pre>zip -r9 work.zip &lt;csv-out&gt;</pre>
</div>
</div>
<div class="section" id="translating">
<span id="using-csv2po-translating"></span><h3>Translating<a class="headerlink" href="#translating" title="Permalink to this headline">¶</a></h3>
<p>Translators can use most Spreadsheets. Excel works well.  However there are a
few problems with spreadsheets:</p>
<ul class="simple">
<li>Encoding &#8211; you can sort that out later</li>
<li>Strings that start with &#8216; &#8211; most spreadsheets treat cells starting with &#8216; as
text and gobble up the &#8216;.  A work around is to escape those like this &#8216;.
po2csv should do this for you.</li>
<li>Autocorrect &#8211; Excel changes ... to a single character and does other odd
things.  pofilter will help catch these later.</li>
<li>Sentences with + &#8211; or +- will create errors and the translators will have to
escape them as + - +-</li>
<li>Sentences that only contain numbers can get broken: &#8220;1.&#8221; will be converted to
&#8220;1&#8221;</li>
</ul>
</div>
<div class="section" id="converting-excel-spreadsheets-to-csv-file">
<span id="using-csv2po-converting-excel-spreadsheets-to-csv-file"></span><h3>Converting Excel spreadsheets to CSV file<a class="headerlink" href="#converting-excel-spreadsheets-to-csv-file" title="Permalink to this headline">¶</a></h3>
<p>You can, and should, keep your files as CSV files.  However, many translators
are not the best wizzes at using their spreadsheet.  In this case many files
will have been changed to XLS files.  To convert them by hand is tedious and
error prone.  Rather make use of <a class="reference external" href="http://freshmeat.net/projects/xlhtml/">xlHtml</a> which can do all the work for you.</p>
<div class="highlight-python"><pre>xlhtml -xp:0 -csv file.xls &gt; file.csv</pre>
</div>
</div>
<div class="section" id="converting-csv-back-to-po">
<span id="using-csv2po-converting-csv-back-to-po"></span><h3>Converting CSV back to PO<a class="headerlink" href="#converting-csv-back-to-po" title="Permalink to this headline">¶</a></h3>
<p>Extract the CSV files here we assume they are in <em>csv-in</em>:</p>
<div class="highlight-python"><pre>csv2po --charset=windows-1250 -t &lt;templates&gt; &lt;csv-in&gt; &lt;po-in&gt;</pre>
</div>
<p>This will create new PO files in <em>po-in</em> based on the CSV files in the <em>csv-in</em>
and the template PO files in <em>templates</em>.  You shouldn&#8217;t run the csv2po command
without templates as this allows you to preserve the original file layout.
Only run it without <tt class="docutils literal"><span class="pre">-t</span></tt> if you are dealing with a partial part of the PO
that you will merge back using a <a class="reference internal" href="../commands/pomerge.html"><em>pomerge</em></a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Running csv2po using the input PO files as templates give spurious
results.  It should probably be made to work but doesn&#8217;t</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You might have encoding problems with the returned files. Use the
<tt class="docutils literal"><span class="pre">--charset</span></tt> option to convert the file from another encoding (all PO
files are created using UTF-8).  Usually Windows user will be using
something like WINDOWS-1250. Check the file after conversion to see that
characters are in fact correct if not try another encoding.</p>
</div>
</div>
<div class="section" id="checking-the-new-po-files">
<span id="using-csv2po-checking-the-new-po-files"></span><h3>Checking the new PO files<a class="headerlink" href="#checking-the-new-po-files" title="Permalink to this headline">¶</a></h3>
<p>Use <a class="reference internal" href="../commands/pofilter.html"><em>pofilter</em></a> to run checks against your new files. Read
<a class="reference internal" href="using_pofilter.html"><em>Checking your files with PO filter</em></a> to get a good idea of how to use the tool.</p>
</div>
<div class="section" id="removing-fuzzies">
<span id="using-csv2po-removing-fuzzies"></span><h3>Removing fuzzies<a class="headerlink" href="#removing-fuzzies" title="Permalink to this headline">¶</a></h3>
<p>When you merge work back that you know is good you want to make sure that it
overrides the fuzzy status of the existing translations, in order to do that
you need to remove the &#8220;#, fuzzy&#8221; markers.</p>
<p>This is best performed against CVS otherwise who knows what changed.</p>
<div class="highlight-bash"><div class="highlight"><pre>po-in-dir<span class="o">=</span>your-incomming-po-files
po-dir<span class="o">=</span>your-existing-po-files

<span class="k">for </span>pofile in <span class="sb">`</span><span class="nb">cd</span> <span class="nv">$po</span>-in-dir; find . -name <span class="s2">&quot;\*.po&quot;</span><span class="sb">`</span>
<span class="k">do</span>
<span class="k">       </span>egrep -v <span class="s2">&quot;^#, fuzzy&quot;</span> &lt; <span class="nv">$po</span>-dir/<span class="nv">$pofile</span> &gt; <span class="nv">$po</span>-dir/<span class="k">${</span><span class="nv">pofile</span><span class="k">}</span>.unfuzzy <span class="o">&amp;&amp;</span> <span class="se">\</span>
       mv <span class="nv">$po</span>-dir/<span class="k">${</span><span class="nv">pofile</span><span class="k">}</span>.unfuzzy <span class="nv">$po</span>-dir/<span class="nv">$pofile</span>
<span class="k">done</span>
</pre></div>
</div>
</div>
<div class="section" id="merging-po-files-into-the-main-po-files">
<span id="using-csv2po-merging-po-files-into-the-main-po-files"></span><h3>Merging PO files into the main PO files<a class="headerlink" href="#merging-po-files-into-the-main-po-files" title="Permalink to this headline">¶</a></h3>
<p>This step would not be necessary if the CSV contained the complete PO file.  It
is only needed when the translator has been editing a subset of the whole PO
file.</p>
<div class="highlight-python"><pre>pomerge --mergeblank=no -t po-dir -i po-in -o po-dir</pre>
</div>
<p>This will take PO files from <em>po-in</em> merge them with those in <em>po-dir</em> using
<em>po-dir</em> as the template &#8211; i.e. overwriting files in <em>po-dir</em>. It will also
ignore entries that have blank msgstr&#8217;s i.e. it will not merge untranslated
items. The default behaviour of pomerge is to take all changes from <em>po-in</em> and
apply them to <em>po-dir</em> by overriding this we can ignore all untranslated items.</p>
<p>There is no option to override the status of the destination PO files with that
of the input PO.  Therefore all your entries that were fuzzy in the destination
will still be fuzzy even thought the input was corrected.  If you are confident
that all your input is correct then relook at the previous section on removing
fuzzies.</p>
</div>
</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>