PHPackages                             mhndev/localization - 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. mhndev/localization

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

mhndev/localization
===================

Php localization

1.3.4(8y ago)2243MITPHPPHP &gt;=5.6.0

Since Apr 12Pushed 8y ago2 watchersCompare

[ Source](https://github.com/mhndev/localization)[ Packagist](https://packagist.org/packages/mhndev/localization)[ Docs](http://github.com/mhndev/localization)[ RSS](/packages/mhndev-localization/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (5)Versions (11)Used By (0)

[![Build Status](https://camo.githubusercontent.com/d2a28b77ea90b80a25fd72aa1cbe17735a00d9c4440c094b8937182d6e749230/68747470733a2f2f7472617669732d63692e6f72672f6d686e6465762f6c6f63616c697a6174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mhndev/localization)[![Latest Stable Version](https://camo.githubusercontent.com/e3045cf729e556051016d4ab79304f5fc5b8d8059288c26bf55fcb5a0f10fe8b/68747470733a2f2f706f7365722e707567782e6f72672f6d686e6465762f6c6f63616c697a6174696f6e2f762f737461626c65)](https://packagist.org/packages/mhndev/localization)[![Latest Unstable Version](https://camo.githubusercontent.com/63d3ddf3a9d557931587dae14e02f981a360292cf252f8832d7bb2e15dc12029/68747470733a2f2f706f7365722e707567782e6f72672f6d686e6465762f6c6f63616c697a6174696f6e2f762f756e737461626c65)](https://packagist.org/packages/mhndev/localization)[![License](https://camo.githubusercontent.com/b8c7236c0ff1d97f5ded9c146f493071c43f2fa91298c3852182fcd5156c1256/68747470733a2f2f706f7365722e707567782e6f72672f6d686e6465762f6c6f63616c697a6174696f6e2f6c6963656e7365)](https://packagist.org/packages/mhndev/localization)[![composer.lock available](https://camo.githubusercontent.com/83b9a353a846e67e28d057a27d06c70034c2414a862bba96d14045588f30dd23/68747470733a2f2f706f7365722e707567782e6f72672f6d686e6465762f6c6f63616c697a6174696f6e2f636f6d706f7365726c6f636b)](https://packagist.org/packages/mhndev/localization)

Localization i18n
=================

[](#localization-i18n)

#### sample code

[](#sample-code)

```
use mhndev\localization\LanguageFactory;
use mhndev\localization\LanguageLoader;
use mhndev\localization\repositories\PhpArray;
use mhndev\localization\Translator;

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

include_once 'vendor/autoload.php';

$repository = new PhpArray(getcwd().DIRECTORY_SEPARATOR.'en.php');
$lang_en = LanguageFactory::fromCountryCode('us')->setRepository($repository);

$repository = new PhpArray(getcwd().DIRECTORY_SEPARATOR.'fa.php');
$lang_fa = LanguageFactory::fromUrlCode('fa')->setRepository($repository);

$translator = new Translator();

$translator->addLanguage($lang_en);
$translator->addLanguage($lang_fa);

$params = [
    'name' => 'مجید',
    'job' => 'برنامه نویس',
    'company' => 'دیجی پیک'
];

$result = $translator->translate(
    'greet',
    LanguageFactory::fromUrlCode('fa'),
    $params
);

var_dump($result);

/*
 * output would be :
 *
 * today is پنجشنبه ۲۴ فروردین ۱۳۹۶  - ۱۰:۵۶ and yesterday was :چهارشنبه ۲۳ فروردین ۱۳۹۶  - ۱۰:۵۶
 *
 * سلام من مجید هستم . من یک برنامه نویس هستم و در شرکت دیجی پیک کار میکنم
 */

echo ''.$result.'';

date_default_timezone_set('Asia/Tehran');
$now = time();

$yesterday = $now - 3600 * 24;

$string = 'today is {{'.$now.'|date }} and yesterday was :{{'.$yesterday.'| date}}';

/*
 * output would be :
 *
 * today is پنجشنبه ۲۴ فروردین ۱۳۹۶ - ۱۰:۵۶ and yesterday was :چهارشنبه ۲۳ فروردین ۱۳۹۶ - ۱۰:۵۶
 */

$translation = $translator->localizeText($string, LanguageFactory::fromUrlCode('fa'));

echo '';

echo $translation;

$lngLoader = new LanguageLoader();

$language = LanguageFactory::fromUrlCode('en');

$languageDetector = new \mhndev\localization\LanguageDetector();
$languageDetector->registerStrategy(new \mhndev\localization\strategies\StrategyUriChunk());
$languageDetector->registerStrategy(new \mhndev\localization\strategies\StrategyQueryParameter());
$languageDetector->registerStrategy(new \mhndev\localization\strategies\StrategyAcceptLngHeader());

$request = \GuzzleHttp\Psr7\ServerRequest::fromGlobals()->withUri(new \GuzzleHttp\Psr7\Uri(
    'http://example.com/fa/some/random/address?key=value'
));

$result = $languageDetector->detect($request);

var_dump($result);
die();
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95.5% 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 ~22 days

Recently: every ~47 days

Total

10

Last Release

3113d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c3e5d182214e2e6b989a2230bcae80b2107b088da1c6dbea6f6f8d28702e272?d=identicon)[majidphpdeveloper](/maintainers/majidphpdeveloper)

---

Top Contributors

[![mhndev](https://avatars.githubusercontent.com/u/5164182?v=4)](https://github.com/mhndev "mhndev (21 commits)")[![majidakbari](https://avatars.githubusercontent.com/u/17963906?v=4)](https://github.com/majidakbari "majidakbari (1 commits)")

---

Tags

i18nlocalizationtranslationlocalizationi18nlanguage

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mhndev-localization/health.svg)

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

###  Alternatives

[gettext/languages

gettext languages with plural rules

7530.3M10](/packages/gettext-languages)[aplus/language

Aplus Framework Language Library

2351.7M15](/packages/aplus-language)[tractorcow/silverstripe-fluent

Simple localisation for Silverstripe

92421.6k26](/packages/tractorcow-silverstripe-fluent)[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[pmochine/laravel-tongue

🎉 Finally a subdomain localization that works how you want it to work. 🌐

4158.4k](/packages/pmochine-laravel-tongue)[fisharebest/localization

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

3191.1k2](/packages/fisharebest-localization)

PHPackages © 2026

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