PHPackages                             rayamedia/yima-localize - 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. rayamedia/yima-localize

ActiveYima-core-module[Localization &amp; i18n](/categories/localization)

rayamedia/yima-localize
=======================

Localization features for multilingual DB`s(translatable fields), CLDR data for full system localization of data, and many predefined useful locale helpers.

021PHP

Since Sep 8Pushed 11y ago1 watchersCompare

[ Source](https://github.com/YiMAproject/yimaLocalize)[ Packagist](https://packagist.org/packages/rayamedia/yima-localize)[ RSS](/packages/rayamedia-yima-localize/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

yimaLocalize
============

[](#yimalocalize)

*this module is part of Yima Application Framework*

\[zf2 module\] Localization features for multilingual DB`s(translatable fields), CLDR data for full system localization of data, and many predefined useful locale helpers.

Using MultiLingual TableGateway Feature
---------------------------------------

[](#using-multilingual-tablegateway-feature)

#### Setup Database

[](#setup-database)

1. Setup Database adapter inside your application.
2. Create new db in your sql server.
3. Create i18n table with importing yimaLocalize\_i18n.sql into your mysql server. *you can find this file inside data folder of module*

#### Create your Translatable Table

[](#create-your-translatable-table)

note: you can register this table as service in serviceManager, later you can invoke this table from SM.

```
use yimaBase\Db\TableGateway\AbstractTableGateway;
use yimaLocalize\Db\TableGateway\Feature\TranslatableFeature;

class SampleTable extends AbstractTableGateway
{
	# db table name
    protected $table = 'sampletable';

	// this way you speed up running by avoiding metadata call to reach primary key
	// exp. usage in Translation Feature
	protected $primaryKey = 'sampletable_id';

	public function init()
	{
		// this is translatable fields of table
		$feature = new TranslatableFeature(
            array('title', 'description')
        );

		$this->featureSet->addFeature($feature);
	}
}
```

In your controller or somewhere you access ServiceManager, you have this stuff:

1. Add Data In Your Current Locale note: when we fetch data from sql only get data inserted from within related locale that insert query was run

```
$serviceLocator = $this->getServiceLocator();
// get sample table service
$projectTable   = $serviceLocator->get('yimaLocalize.Model.TableGateway.Sample');

$locale         = \Locale::getDefault();
$title = ($locale == 'fa_IR') ? 'عنوان' : 'Title';
$descr = ($locale == 'fa_IR') ? 'توضیحات' : 'Description';

// Translatable Feature will automatically detect locale from \Locale::getDefault()
$projectTable->insert(
    array(
        'title' 	  => $title,
        'description' => $descr,
        'image'       => uniqid().'.jpg',
    )
);

// we can also use update query as well
$projectTable->update(
    array(
        'description' => 'This is '.$locale.' title updated from',
    ),
    array('sampletable_id'=>1 )
);
```

2. Add Translation for data table in other locale language(s) note: every time you query for data in desired locale language translation will fetch automatically

```
$serviceLocator = $this->getServiceLocator();
// get sample table service
$projectTable   = $serviceLocator->get('yimaLocalize.Model.TableGateway.Sample');

$locale         = \Locale::getDefault();
$title = ($locale == 'fa_IR') ? 'عنوان' : 'Title';
$descr = ($locale == 'fa_IR') ? 'توضیحات' : 'Description';

$projectTable->insert(
    array(
        'title' 	  => $title,
        'description' => $descr,
        'image'       => uniqid().'.jpg',
    )
);

$currentLocale = $locale;
$transLocale   = 'fa_IR';

// add translation for other locale ... {
// set locale for translation feature
$projectTable->apply('setLocale', array($transLocale));
// add translation
$projectTable->apply(
    'addTranslationRows',
    array(
        array(
            'title' 	  => $transLocale.' Title',
            'description' => $transLocale.' Description',
        )
    ,$projectTable->getLastInsertValue()
    )
);
// bring back current locale, as you want !!
$projectTable->apply('setLocale', array($currentLocale));
// ... }
```

3. Fetch, Update, Delete From Table

```
$projectTable->apply('setLocale', array('fa_IR'));

// Select Specific Data For "fa_IR" locale
$select = $projectTable->getSql()->select()
    //->columns(array('t'=>'title','image','url'))
    //->where(array('sampletable_id' => 1))
;
$rowset = $projectTable->selectWith($select);

foreach ($rowset as $projectRow) {
    \Zend\Debug\Debug::dump($projectRow);
}

// Delete Query Will Remove All Data And Translation
$projectTable->delete(
    array('sampletable_id'=>1 )
);
```

Using Localized Calendar
------------------------

[](#using-localized-calendar)

this is one of locale() helper plugins that convert dates to localized result. lets see some examples.

```
# in view or controllers as helper

# Determine the detected locale is fa_IR

echo $this->locale(); // fa_IR
// this will print out date in persian calendar
echo $this->locale()->datetime()->format('Y-m-d H:i:s'); // 1393-03-07 21:53:30

# Determine the detected locale is nl_BE

echo $this->locale(); // nl_BE
// this will print out date in persian calendar
echo $this->locale()->datetime()->format('Y-M-d l'); // 2014-mei-28 woensdag
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f784f9dfb58e36b6a876f3057e5664bb904af71d30bb2023583118138dffe9a?d=identicon)[Payam](/maintainers/Payam)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/rayamedia-yima-localize/health.svg)

```
[![Health](https://phpackages.com/badges/rayamedia-yima-localize/health.svg)](https://phpackages.com/packages/rayamedia-yima-localize)
```

###  Alternatives

[smarty-gettext/smarty-gettext

Gettext plugin enabling internationalization in Smarty Package files

752.5M8](/packages/smarty-gettext-smarty-gettext)[renatomarinho/laravel-multi-language

Laravel Multi Language

235.1k](/packages/renatomarinho-laravel-multi-language)

PHPackages © 2026

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