PHPackages                             biohzrdmx/pomoh-php - 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. biohzrdmx/pomoh-php

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

biohzrdmx/pomoh-php
===================

Translation abstraction library for PO/MO files

1.0.1(1y ago)010MITPHPPHP &gt;=8.2

Since Mar 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/biohzrdmx/pomoh-php)[ Packagist](https://packagist.org/packages/biohzrdmx/pomoh-php)[ RSS](/packages/biohzrdmx-pomoh-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

pomoh-php
=========

[](#pomoh-php)

Translation abstraction library for PO/MO files

Make your projects translatable with the use of PO/MO files with or without `ext-gettext`.

### Basic usage

[](#basic-usage)

First require `biohzrdmx/pomoh-php` with Composer.

#### Creating a `Translator` instance

[](#creating-a-translator-instance)

Then create a `Translator` instance:

```
use PoMoh\Translator;

$translator = new Translator($adapter);
```

#### Adapters

[](#adapters)

You will need to pass an `AdapterInterface` implementation instance; PoMoh includes two:

- `GetTextAdapter` - Use the built-in gettext functions, requires `ext-gettext`
- `MoFileAdapter` - Load and parse MO files in runtime, doesn't require `ext-gettext` but may be a little slower

For example, to use `GetTextAdapter`:

```
use PoMoh\Translator;
use PoMoh\Adapter\GetTextAdapter;

$adapter = new GetTextAdapter('es_ES', 'pomoh', dirname(__FILE__) . '/lang');
$translator = new Translator($adapter);
```

As you can see you will need to pass the language identifier, the text-domain and the directory where the translations reside, according to the `//LC_MESSAGES/.mo` structure, for example:

```
/lang/es_ES/LC_MESSAGES/pomoh.po
/lang/es_ES/LC_MESSAGES/pomoh.mo
/lang/de_DE/LC_MESSAGES/pomoh.po
/lang/de_DE/LC_MESSAGES/pomoh.mo
/lang/fr_FR/LC_MESSAGES/pomoh.po
/lang/fr_FR/LC_MESSAGES/pomoh.mo

```

If you can not (or don't want to) use `ext-gettext` you can leverage the `MoFileAdapter`:

```
use PoMoh\Translator;
use PoMoh\Adapter\MoFileAdapter;

$adapter = new MoFileAdapter('es_MX', dirname(__FILE__) . '/lang');
$translator = new Translator($adapter);
```

This adapter takes only two parameters, the language code and the directory where the translations reside, according to the `/.mo` structure, for example:

```
/lang/es_ES.po
/lang/es_ES.mo
/lang/de_DE.po
/lang/de_DE.mo
/lang/fr_FR.po
/lang/fr_FR.mo

```

#### Translating strings

[](#translating-strings)

Once you have a `Translator` instance just call the `translate` method:

```
$string = $translator->translate('This is a string');
```

#### Pluralization

[](#pluralization)

The library includes basic support for pluralization through the `pluralize` method:

```
$string = $translator->pluralize('A fox', '%d foxes', 5);
```

Pluralization rules are either handled by `ngettext` or directly loaded from the MO file; either way they are language dependent.

If no pluralization rules are found the default one will be used (`nplurals=2; plural=n == 1 ? 0 : 1;`).

### Acknowledgements

[](#acknowledgements)

This library includes code from other projects, namely:

- [phpmyadmin/motranslator](https://github.com/phpmyadmin/motranslator) - GPL Licensed
- [WordPress/WordPress](https://github.com/WordPress/WordPress) - GPL Licensed

### Licensing

[](#licensing)

This software is released under the MIT license.

Copyright © 2025 biohzrdmx

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

### Credits

[](#credits)

**Lead coder:** biohzrdmx &lt;[github.com/biohzrdmx](http://github.com/biohzrdmx)&gt;

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance48

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~26 days

Total

2

Last Release

384d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44b968bb45d47a621ce8e81c422ef4c126316a702156a7faf96df75610cc0d45?d=identicon)[biohzrdmx](/maintainers/biohzrdmx)

---

Top Contributors

[![biohzrdmx](https://avatars.githubusercontent.com/u/2053303?v=4)](https://github.com/biohzrdmx "biohzrdmx (4 commits)")

### Embed Badge

![Health badge](/badges/biohzrdmx-pomoh-php/health.svg)

```
[![Health](https://phpackages.com/badges/biohzrdmx-pomoh-php/health.svg)](https://phpackages.com/packages/biohzrdmx-pomoh-php)
```

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)

PHPackages © 2026

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