2017 © Pedro PelĂĄez
 

library po-parser

Gettext *.PO file parser for PHP.

image

mentor/po-parser

Gettext *.PO file parser for PHP.

  • Tuesday, October 10, 2017
  • by mentor
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,600 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 51 Forks
  • 0 Open issues
  • 15 Versions
  • 9 % Grown

The README.md

Po Parser

Latest Stable Version Total Downloads License Build Status Code Coverage Scrutinizer Quality Score ![Gitter](https://badges.gitter.im/Join Chat.svg), (*1)

PoParser is a personal project to fulfill a need I got: parse Gettext Portable files (*.po files) and edit its content using PHP., (*2)

PoParser will allow you to read PO Data from any source (files and strings built-in), update it and store back to a file (or get the compiled string)., (*3)

It supports following parsing features:, (*4)

  • header section.
  • msgid, both single and multiline.
  • msgstr, both single and multiline.
  • msgctxt (Message context).
  • msgid_plural (plurals forms).
  • #, keys (flags).
  • # keys (translator comments).
  • #. keys (Comments extracted from source code).
  • #: keys (references).
  • #| keys (previously untranslated), both single and multiline.
  • #~ keys (old entries), both single and multiline.

Usage

// Parse a po file
$fileHandler = new Sepia\FileHandler('es.po');

$poParser = new Sepia\PoParser($fileHandler);
$entries  = $poParser->parse();
// $entries contains every entry in es.po file.

// Update entries
$msgid = 'Press this button to save';
$entries[$msgid]['msgstr'] = 'Pulsa este botĂłn para guardar';
$poParser->setEntry($msgid, $entries[$msgid]);
// You can also change translator comments, code comments, flags...

Changelog

v5.0 (WIP) * Classes are now fluid. * Namespaces reorganized. * Removed fuzzy index in favour of flags. * Display line number on parsing errors instead of line content. * Adds compatibility with #~| entries. * parseString() and parseFile() converted to factory methods. * Removed method updateEntry() in favour of setEntry()., (*5)

v4.2.2 * More PHPDocs fixes * Strict comparisons used where safe. * Fix example for writeFile. * Support for EOL line formatting., (*6)

v4.2.1 * Support multiline for plural entries (thanks @Ben-Ho), (*7)

v4.2.0 * Add function to add plural and context to existing entry (thanks @Ben-Ho) * Add ability to change msg id of entry (thanks @wildex), (*8)

v4.1.1 * Fixes with multi-flags entries (thanks @gnouet), (*9)

v4.1 * Constructor now accepts options to define separator used in multiline msgid entries. * New method getOptions()., (*10)

v4.0, (*11)

  • new methods parseString() and parseFile() replace the old parse()`
  • new method writeFile() replaces the old write().
  • new method compile() which takes all parsed entries and coverts back to a PO formatted string.

See whole changelog, (*12)

Documentation

See v4 documentation, (*13)

Testing

Tests are done using PHPUnit. To execute tests, from command line type:, (*14)

php vendor/bin/phpunit

Install via composer

Edit your composer.json file to include the following:, (*15)

{
    "require": {
        "sepia/po-parser": "dev-master"
    }
}

The Versions

10/10 2017

dev-master

9999999-dev https://github.com/mentor/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

09/02 2016

5.0.x-dev

5.0.9999999.9999999-dev https://github.com/raulferras/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

09/06 2015

4.2.1

4.2.1.0 https://github.com/raulferras/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

12/02 2015

dev-scrutinizer-patch-1

dev-scrutinizer-patch-1 https://github.com/raulferras/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

22/01 2015

4.2.0

4.2.0.0 https://github.com/raulferras/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

31/10 2014

4.1.1

4.1.1.0 https://github.com/raulferras/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

27/10 2014

4.0.1

4.0.1.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

27/10 2014

4.0.0

4.0.0.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

16/10 2014

4.1.0

4.1.0.0 https://github.com/raulferras/PHP-po-parser

Gettext *.PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

18/06 2014

3.0.5

3.0.5.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

21/03 2014

3.0.4

3.0.4.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

23/01 2014

3.0.3

3.0.3.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

15/01 2014

3.0.2

3.0.2.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

09/12 2013

3.0.1

3.0.1.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n

08/12 2013

3.0.0

3.0.0.0 https://github.com/raulferras/PHP-po-parser

PO file parser for PHP.

  Sources   Download

MIT

The Development Requires

by RaĂșl FerrĂ s

i18n gettext po i10n