Suppose I have a example.php file like that:

<p>
  <?php echo _('Hello world') ?>
</p>
<p>
  <b><?php echo _('the end') ?>
</p>

If I extract strings:

xgettext example.php

I get a messages.mo file, that I can open with poedit, translate, create a .po file, etc. That's ok, the problem is when I edit my original and already translated example.php:

<p>
  <?php echo _('Hello world') ?>
</p>
<p>
  <?php echo _('new string') ?>
</p>
<p>
  <b><?php echo _('the end') ?>
</p>

I've added a new string and if I execute xgettext again I get a messages.mo file where all strings are empty, so I have to use poedit and translate again all strings. How can I re-use my previous translations?

有帮助吗?

解决方案

You can merge two po files together with msgmerge. If the source string is unchanged the merge should work perfectly, if it has changed you obviously may have to do some work to get things translated again, and of course you will have to translate any entirely new strings.

msgmerge -o results.po my_existing_translations.po untranslated_xgettext_output.po
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top