saeven/circlical-po-editor

Gettext *.PO file editor and parser for PHP.

Maintainers

👁 Saeven

Package info

github.com/Saeven/circlical-po-editor

Homepage

Issues

pkg:composer/saeven/circlical-po-editor

Statistics

Installs: 8 130

Dependents: 1

Suggesters: 0

Stars: 11

0.9.1 2017-09-19 02:52 UTC

Requires

  • php: >=5.5.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 64738b5305fe22a2e75257e0f436323fde84462a

  • Alexandre Lemaire <alemaire.woop@circlical.com>

i18ngettextpoi10n

This package is auto-updated.

Last update: 2026-06-14 22:27:04 UTC


README

👁 Build Status

PHP Parser/Editor for Gettext PO files

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.

This repository is thoroughly tested, mosts tests were taken from raulferras/PHP-po-parser, thank you!

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.)

When you parse a po file, it transforms it into blocks that you can cleanly manipulate to thereafter compile.

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:

#: wp-admin/install.php:177
msgid "welcome"
msgstr "welcome"

to:

#: wp-admin/install.php:177
msgid "welcome"
msgstr "hola"