PHP Gettext Translation Editor
, (*1)
PHP Parser/Editor for Gettext PO files, (*2)
PoEditor is a class that allows you to load / parse / manipulate / compile .po files using PHP. I built this to support a web-based PO file editor., (*3)
This repository is thoroughly tested, mosts tests were taken from raulferras/PHP-po-parser, thank you!, (*4)
It supports all of the same features, with a simpler and stable interface:
* headers (HeaderBlock)
* msgid (message id)
* msgstr (translation strings)
* msgctxt (context)
* msgid_plural (plural translations)
* # (flags, comments, source, references, annotations, etc.), (*5)
When you parse a po file, it transforms it into blocks that you can cleanly manipulate to thereafter compile., (*6)
Usage
Parsing Files
$po = new Circlical\PoEditor( 'file.po' );
$po->parse();
Editing Blocks
$po = new Circlical\PoEditor( 'file.po' );
$po->parse();
$po->getBlock( 'welcome' )->setMsgstr( "hola" );
$po->compile();
That transforms file.po from:, (*7)
#: wp-admin/install.php:177
msgid "welcome"
msgstr "welcome"
to:, (*8)
#: wp-admin/install.php:177
msgid "welcome"
msgstr "hola"