PHPackages                             mentor/po-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. mentor/po-parser

ActiveLibrary[Localization &amp; i18n](/categories/localization)

mentor/po-parser
================

Gettext \*.PO file parser for PHP.

4.2.1(10y ago)038.5k↓33.3%MITPHPPHP &gt;=5.3.0

Since Dec 8Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mentor/PHP-po-parser)[ Packagist](https://packagist.org/packages/mentor/po-parser)[ Docs](https://github.com/raulferras/PHP-po-parser)[ RSS](/packages/mentor-po-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (15)Used By (0)

Po Parser
=========

[](#po-parser)

[![Latest Stable Version](https://camo.githubusercontent.com/6dc6fa175bb020c9179925a9fbdd84708526d467063f57d279ab9170cd87724d/68747470733a2f2f706f7365722e707567782e6f72672f73657069612f706f2d7061727365722f762f737461626c65)](https://packagist.org/packages/sepia/po-parser)[![Total Downloads](https://camo.githubusercontent.com/57e28e9c28eb4ea642b9eac2fb2c96e8476b6c1aded359589ccb9ba199b7a2b8/68747470733a2f2f706f7365722e707567782e6f72672f73657069612f706f2d7061727365722f646f776e6c6f616473)](https://packagist.org/packages/sepia/po-parser)[![License](https://camo.githubusercontent.com/8e9f220cf6b7d271798e660aaa9406ca3fc74ff81084864180c401f63d08ddb5/68747470733a2f2f706f7365722e707567782e6f72672f73657069612f706f2d7061727365722f6c6963656e7365)](https://packagist.org/packages/sepia/po-parser)[![Build Status](https://camo.githubusercontent.com/fe754b607c58bb1126e31089a226d928e421d38a72451fcdf5081bfcae611d5c/68747470733a2f2f7472617669732d63692e6f72672f7261756c6665727261732f5048502d706f2d7061727365722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/raulferras/PHP-po-parser)[![Code Coverage](https://camo.githubusercontent.com/30f672c82a52bb7c3a4158b6eee72d1ae31a1d237bb470f27ad190abc5fb55c2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261756c6665727261732f5048502d706f2d7061727365722f6261646765732f636f7665726167652e706e673f733d61313965636532613835343362303835616231613564623331396465643362633435333062353637)](https://scrutinizer-ci.com/g/raulferras/PHP-po-parser/)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/d6685633ea5f8a3f352a63c518bf2d8fe3d470fdce29ddf7b37bd3f890975cea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7261756c6665727261732f5048502d706f2d7061727365722f6261646765732f7175616c6974792d73636f72652e706e673f733d36616166336333316365313563656264316434626564373138636434316664326439323166643331)](https://scrutinizer-ci.com/g/raulferras/PHP-po-parser/)[!\[Gitter\](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/raulferras/PHP-po-parser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

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

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

It supports following parsing features:

- 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-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
=====

[](#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
=========

[](#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()`.

v4.2.2

- More PHPDocs fixes
- Strict comparisons used where safe.
- Fix example for `writeFile`.
- Support for EOL line formatting.

v4.2.1

- Support multiline for plural entries (thanks @Ben-Ho)

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)

v4.1.1

- Fixes with multi-flags entries (thanks @gnouet)

v4.1

- Constructor now accepts options to define separator used in multiline msgid entries.
- New method `getOptions()`.

v4.0

- 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](https://github.com/raulferras/PHP-po-parser/wiki/Changelog)

Documentation
=============

[](#documentation)

[See v4 documentation](https://github.com/raulferras/PHP-po-parser/wiki/Documentation-4.0)

Testing
=======

[](#testing)

Tests are done using PHPUnit. To execute tests, from command line type:

```
php vendor/bin/phpunit

```

Install via composer
====================

[](#install-via-composer)

Edit your composer.json file to include the following:

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

```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~66 days

Recently: every ~117 days

Total

13

Last Release

3751d ago

Major Versions

3.0.5 → 4.1.02014-10-16

4.2.1 → 5.0.x-dev2016-02-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/128702?v=4)[Andrej Litvaj](/maintainers/mentor)[@mentor](https://github.com/mentor)

---

Top Contributors

[![pherrymason](https://avatars.githubusercontent.com/u/1103977?v=4)](https://github.com/pherrymason "pherrymason (54 commits)")[![newage](https://avatars.githubusercontent.com/u/426997?v=4)](https://github.com/newage "newage (9 commits)")[![Ben-Ho](https://avatars.githubusercontent.com/u/1324250?v=4)](https://github.com/Ben-Ho "Ben-Ho (4 commits)")[![felixgilles](https://avatars.githubusercontent.com/u/900854?v=4)](https://github.com/felixgilles "felixgilles (3 commits)")[![mentor](https://avatars.githubusercontent.com/u/128702?v=4)](https://github.com/mentor "mentor (3 commits)")[![ADmad](https://avatars.githubusercontent.com/u/142658?v=4)](https://github.com/ADmad "ADmad (2 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![dexif](https://avatars.githubusercontent.com/u/387234?v=4)](https://github.com/dexif "dexif (1 commits)")[![dsas](https://avatars.githubusercontent.com/u/93301?v=4)](https://github.com/dsas "dsas (1 commits)")[![fmasa](https://avatars.githubusercontent.com/u/5658260?v=4)](https://github.com/fmasa "fmasa (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![Ivan-Perez](https://avatars.githubusercontent.com/u/3533970?v=4)](https://github.com/Ivan-Perez "Ivan-Perez (1 commits)")

---

Tags

i18ngettextpoi10n

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mentor-po-parser/health.svg)

```
[![Health](https://phpackages.com/badges/mentor-po-parser/health.svg)](https://phpackages.com/packages/mentor-po-parser)
```

###  Alternatives

[gettext/gettext

PHP gettext manager

70130.2M102](/packages/gettext-gettext)[sepia/po-parser

Gettext \*.PO file parser for PHP.

1271.5M19](/packages/sepia-po-parser)[phpmyadmin/motranslator

Translation API for PHP using Gettext MO files

591.8M8](/packages/phpmyadmin-motranslator)[saeven/circlical-po-editor

Gettext \*.PO file editor and parser for PHP.

118.1k](/packages/saeven-circlical-po-editor)[maxakawizard/po-parser

Gettext \*.po parser for PHP

1771.5k](/packages/maxakawizard-po-parser)[gettext/translator

Gettext translator functions

114.6M10](/packages/gettext-translator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
