문제

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