Gettext *.po parser for PHP

1.2.1 2015-11-10 23:37 UTC

This package is auto-updated.

Last update: 2020-03-29 16:14:26 UTC


Build Status Scrutinizer Code Quality Code Climate Coverage Status SensioLabs Insight

GitHub tag Packagist Packagist

Minimum PHP Version License

Gettext *.po files parser for PHP.

This package is compliant with PSR-4, PSR-1, and PSR-2. If you notice compliance oversights, please send a patch via pull request.


Read file content

$parser = new PoParser\Parser();
$entries = $parser->getEntriesAsArrays();
// Now $entries contains every string information in your pofile

echo '<ul>';
foreach ($entries as $entry) {
   echo '<li>'.
   '<b>msgid:</b> '.$entry['msgid'].'<br>'.         // Message ID
   '<b>msgstr:</b> '.$entry['msgstr'].'<br>'.       // Translation
   '<b>reference:</b> '.$entry['reference'].'<br>'. // Reference
   '<b>msgctxt:</b> ' . $entry['msgctxt'].'<br>'.   // Message Context
   '<b>tcomment:</b> ' . $entry['tcomment'].'<br>'. // Translator comment
   '<b>ccomment:</b> ' . $entry['ccomment'].'<br>'. // Code Comment
   '<b>obsolete?:</b> '.(string)$entry['obsolete'].'<br>'. // Is obsolete?
    '<b>fuzzy?:</b> ' .(string)$entry['fuzzy'].     // Is fuzzy?
echo '</ul>';

Modify content

$parser = new PoParser\Parser();
// Entries are stored in array, so you can modify them.

// Use updateEntry method to change messages you want.
$parser->updateEntry('Write your email', 'Escribe tu email');


  • Improve entries edit interface
  • Ability to change any entry fields
  • Discover what's the meaning of "#@ " line
  • Fix multiline msgstr processing (for singular and plural entries)
  • Implement previous untranslated strings support


This library is released under MIT license.