Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Babel: How to protect translator comments (and old translations) in GNU gettext PO files?
    text
    copied!<p>With the Python-based <a href="http://babel.pocoo.org/" rel="nofollow noreferrer">Babel</a> gettext utilities, are there any techniques to preserve translator comments and old ("obsolete") translations (marked with <code>#~</code>) in <code>.po</code> files across updates from the <code>.pot</code> file?</p> <p>The first time an obsolete translation is in a <code>.po</code> file, and <code>pybabel update</code> is run, the translation is marked with <code>#~</code>. This is so that on the one hand, it is treated as a comment and not used until a translator looks it over and changes it, yet on the other hand, it is not removed, so a translator can refer to it, or copy text from it into their other translations.</p> <p>However, the next time <code>pybabel update</code> is run, all comments are permanently removed from the file. This means those translations marked with <code>#~</code> are removed, too.</p> <p>For example, with Babel version 0.9.6 and <a href="http://jinja.pocoo.org/" rel="nofollow noreferrer">Jinja2</a> version 2.6, and the following files:</p> <p><strong><code>./babel.ini</code></strong>:</p> <pre><code>[jinja2: **/templates/**.html] encoding = utf-8 </code></pre> <p><strong><code>./templates/test.html</code></strong>:</p> <pre><code>&lt;html&gt;&lt;body&gt; &lt;h1&gt;{% trans %}My website{% endtrans %}&lt;/h1&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p><strong><code>./i18n/pt_PT/LC_MESSAGES/messages.po</code></strong>:</p> <pre><code># ... header stuff generated from # pybabel init -l pt_PT -d i18n -i i18n/messages.pot ... # Don't forget, I want to remember something about this! #~ msgid "My web page" #~ msgstr "A minha página de web" </code></pre> <p>After the following commands are run:</p> <pre><code>$ pybabel extract -F babel.ini -o i18n/messages.pot . $ pybabel update -l pt_PT -d i18n -i i18n/messages.pot </code></pre> <p>The Portuguese <code>messages.po</code> file loses all its old comments, and contains only:</p> <p><strong><code>./i18n/pt_PT/LC_MESSAGES/messages.po</code></strong>:</p> <pre><code># ... similar header stuff ... #: templates/test.html:2 msgid "My web site" msgstr "" </code></pre> <p>How can I update my translation files without losing my comments and old translations?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload