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

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

geekwright/po
=============

Objects to assist in reading, manipulating and creating GNU gettext style PO files

v2.0.2(5y ago)4232.6k↑83.4%34GPL-2.0-or-laterPHPPHP &gt;7.1CI failing

Since Mar 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/geekwright/Po)[ Packagist](https://packagist.org/packages/geekwright/po)[ Docs](https://github.com/geekwright/Po)[ RSS](/packages/geekwright-po/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (4)

Po
==

[](#po)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/dfb0986bba02da0406a4a981d7bca7e5b623497a182e435eb74a98bbf343c97e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6765656b7772696768742f506f2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/geekwright/Po/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/d6a52807b18d504d69dab5eace6913dc9af631a98f0f52a0d29e5b5676d699a3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6765656b7772696768742f506f2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/geekwright/Po/?branch=master) [![Build Status](https://camo.githubusercontent.com/eeb04a28647409a42f74fca0e40ccf6b94257cd0ca322c026586c1e18870a6c5/68747470733a2f2f7472617669732d63692e6f72672f6765656b7772696768742f506f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/geekwright/Po)

**Po** is a set of objects to assist in reading, manipulating and creating GNU gettext style PO files.

Installing
----------

[](#installing)

The recommended installation method is using [composer](https://getcomposer.org/). To add *"geekwright/po"* to your composer managed project, use this command:

```
composer require geekwright/po

```

PHP Support
-----------

[](#php-support)

**Po** version 1 supports PHP 5.3 and above. Begining with version 2, **Po** requires a minimum of **PHP 7.1**.

Namespace
---------

[](#namespace)

All **Po** classes are in the `Geekwright\Po` namespace.

Examples
--------

[](#examples)

**Po** provides the capability to create, read, and modify PO and POT files, including the ability to scan PHP sources for gettext style calls to build a POT file. You can connect the pieces however you need, but here are a few examples for common situations.

### Reading a PO File

[](#reading-a-po-file)

```
    try {
        $poFile = new PoFile();
        $poFile->readPoFile('test.po');
        // list all the messages in the file
        $entries = $poFile->getEntries();
        foreach($entries as $entry) {
            echo $entry->getAsString(PoTokens::MESSAGE);
        }
    } catch (UnrecognizedInputException $e) {
        // we had unrecognized lines in the file, decide what to do
    } catch (FileNotReadableException $e) {
        // the file couldn't be read, nothing happened
    }
```

### Get the Plural-Forms Header

[](#get-the-plural-forms-header)

```
    $pluralRule = $poFile->getHeaderEntry()->getHeader('plural-forms');
```

### Add a New Entry

[](#add-a-new-entry)

```
    $entry = new PoEntry;
    $entry->set(PoTokens::MESSAGE, 'This is a message.');
    $entry->set(PoTokens::FLAG, 'fuzzy');
    $poFile->addEntry($entry);
```

### Get the Translation for an Entry

[](#get-the-translation-for-an-entry)

The translation for an entry can be a string, or an array of strings if the Entry is a plural form. This code fragment will assign the translation to `$msgstr` appropriate for either case.

```
    $msgid_plural = $entry->get(PoTokens::PLURAL);
    if (empty($msgid_plural)) {
        $msgstr = $entry->getAsString(PoTokens::TRANSLATED);
    } else {
        $msgstr = $entry->getAsStringArray(PoTokens::TRANSLATED);
    }
```

### Writing a PO File

[](#writing-a-po-file)

```
    try {
        $poFile->writePoFile('test.po');
    } catch (FileNotWriteableException $e) {
        // the file couldn't be written
    }
```

### Create a POT File from PHP sources

[](#create-a-pot-file-from-php-sources)

```
    $poFile = new PoFile();
    $poInit = new PoInitPHP($poFile);
    foreach (glob("*.php") as $filename) {
        try {
            $poInit->msginitFile($filename);
        } catch (FileNotReadableException $e) {
            // the souce file couldn't be read, decide what to do
        }
    }
    try {
        $poFile->writePoFile('default.pot');
    } catch (FileNotWriteableException $e) {
        // the file couldn't be written
    }
```

API
---

[](#api)

For more information, see the full Po [API documentation](http://geekwright.github.io/Po/api/).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.3% 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 ~304 days

Recently: every ~493 days

Total

8

Last Release

1987d ago

Major Versions

v1.0.4 → v2.0.02018-02-03

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v2.0.0PHP &gt;7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7eb0c56896d2405e44608ffb77c1411e4a18927be440b28275f7e0cb075ea9d6?d=identicon)[geekwright](/maintainers/geekwright)

---

Top Contributors

[![geekwright](https://avatars.githubusercontent.com/u/3181636?v=4)](https://github.com/geekwright "geekwright (36 commits)")[![mtorromeo](https://avatars.githubusercontent.com/u/51503?v=4)](https://github.com/mtorromeo "mtorromeo (1 commits)")

---

Tags

i18nl10ngettextpopot

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[gettext/gettext

PHP gettext manager

72231.8M114](/packages/gettext-gettext)[sepia/po-parser

Gettext \*.PO file parser for PHP.

1271.5M21](/packages/sepia-po-parser)[gettext/languages

gettext languages with plural rules

7532.0M12](/packages/gettext-languages)[maxakawizard/po-parser

Gettext \*.po parser for PHP

1773.9k](/packages/maxakawizard-po-parser)[fisharebest/localization

A lightweight localization database and translation tools, with data from the CLDR, IANA, ISO, etc.

29101.1k3](/packages/fisharebest-localization)[kunststube/potools

Tools for working with gettext PO files.

133.2k1](/packages/kunststube-potools)

PHPackages © 2026

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