PHPackages                             opencat/filter-po - 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. opencat/filter-po

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

opencat/filter-po
=================

GNU gettext PO file filter for the OpenCAT Framework

10PHP

Since May 9Pushed 2mo agoCompare

[ Source](https://github.com/shaikhammar/opencat-filter-po)[ Packagist](https://packagist.org/packages/opencat/filter-po)[ RSS](/packages/opencat-filter-po/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

catframework/filter-po
======================

[](#catframeworkfilter-po)

GNU gettext PO file filter for the [CAT Framework](https://github.com/shaikhammar/cat-framework).

Installation
------------

[](#installation)

```
composer require catframework/filter-po
```

Usage
-----

[](#usage)

```
use CatFramework\FilterPo\PoFilter;

$filter = new PoFilter();

// Extract translatable segments from a PO file
$document = $filter->extract('messages.po', 'en', 'fr');

foreach ($document->getSegmentPairs() as $pair) {
    echo $pair->source->getPlainText() . PHP_EOL;
    // … send to MT, TM lookup, or human translator …
    $pair->target = new Segment('seg-t', [$translatedText]);
}

// Write the translated PO file
$filter->rebuild($document, 'messages.fr.po');
```

What gets extracted
-------------------

[](#what-gets-extracted)

Entry typeBehaviourNormal `msgid` / `msgstr`Extracted as a segmentHeader (empty `msgid`)Skipped — preserved verbatim in output`#, fuzzy` entriesSkipped — preserved verbatim in outputPlural forms (`msgid_plural`)Singular `msgid` extracted; translation written to `msgstr[0]`; remaining plural slots (`msgstr[1..n]`) set to empty stringMulti-line stringsContinuation lines concatenated and decodedPO escape sequences (`\n`, `\t`, `\"`, `\\`) are decoded on extraction and re-encoded on rebuild.

Skeleton format
---------------

[](#skeleton-format)

The skeleton stored in `BilingualDocument::$skeleton` is:

```
[
    'lines'   => string[],  // full file split by "\n", msgstr blocks replaced by tokens
    'seg_map' => [          // segId => token string
        'seg-1' => '{{SEG:001}}',
        'seg-2' => '{{SEG:002}}',
        // …
    ],
]
```

Limitations
-----------

[](#limitations)

- Plural translations: only `msgstr[0]` is filled; `msgstr[1..n]` require manual post-editing.
- `msgctxt` (message context) is recognised and skipped over during parsing but not exposed as metadata on the segment.
- Binary PO files (`.mo`) are not supported.

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance56

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6b9044413071860fd6199e56c661a24f449797b77a1b130f0df7e98be8481f4?d=identicon)[shaikhammar](/maintainers/shaikhammar)

---

Top Contributors

[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (3 commits)")

### Embed Badge

![Health badge](/badges/opencat-filter-po/health.svg)

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

PHPackages © 2026

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