PHPackages                             joacub/libra-locale - 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. joacub/libra-locale

ActiveLibrary

joacub/libra-locale
===================

Zend Framework 2 Locale Module. It detect locale by individual module and transfer parameter 'locale' to its Controller

0.5.2(12y ago)019BSD-3-ClausePHPPHP &gt;=5.3.3

Since Sep 9Pushed 12y ago1 watchersCompare

[ Source](https://github.com/joacub/libra-locale)[ Packagist](https://packagist.org/packages/joacub/libra-locale)[ Docs](http://www.ejoom.com/libra-cms/)[ RSS](/packages/joacub-libra-locale/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

\#Libra Locale Module

\##Description This module adds locale to yours modules. Also it set default locale site-widely. It makes application locale aware, add locale short aliases like usually used *en*, *fr*, *ru*, instead of long locale tags like *en-US.UTF8*, *en-GB* etc.

\####Note! You can easily add this module to your project as *LibraLocale* keep path for default alias and using any things in the same manner.

\##Using For enabling locale add it modules in application configuration. To disable locale behavior for any module add to root level route of module parameter disable\_locale =&gt; true in routes options

```
    'router' => array(
        'routes' => array(
            'application' => array(
                'type' => 'Segment',
                'options' => array(
                    'route' => '/application',
                    'disable_locale' => true,
                    'constraints' => array(
                        'alias'      => '[a-zA-Z][a-zA-Z0-9_-]*',
                    ),
                    'defaults' => array(
                        ....
                    ),
                    'may_terminate' => true,
                    'child_routes' => array(
                        ....
                    )
                )
            ),
        ....

```

After this you can get locale alias from RouteMatch parameter. In Controller by code:

```
    $locale = $this->params('locale');
    //or
    $locale = $this->getEvent()->getRouteMatch()->getParam('locale');

```

It has a switcher, use by router with param 'to' for locale alias:

```
    echo $this->url('libra-locale/switch', array(), array('query' => array('to' => 'en')));
    echo $this->url('libra-locale/switch', array(), array('query' => array('to' => 'ru')));
    echo $this->url('libra-locale/switch', array(), array('query' => array('to' => 'fr')));

```

\####Checking if locales was enabled To disable locales you can:

- Comment out *locale\_aware* option in route. It should assume working for locale '\*' or 'All' locales with enabled module.
- Disable *LibraLocale* module.

Then to check if application support locales use:

```
    if (\LibraModuleManager\Module::isModulePresent('LibraLocale')) {
        //put code here
    }

```

**Note:** I've just realized there may be added a flag in configuration instead of disabling module. Will be implemented on demand.

Thanks for using it module.

\##Installation It available via composer package *libra/libra-locale*.

- Add to **composer.json** required list: `"libra/libra-locale": "~0.3.0"`
- Enable module in **config/application.config.php** module array by adding line: `'LibraLocale',`
- Copy `vendor/libra/libra-locale/config/libra-locale.global.php.dist` to `config/autoload/libra-locale.global.php`
- Enable it for wished module as described in use paragraph above.

\##Changelog #####0.5.0 After some experience I decided to make default locale path as '/' instead of '/locale/' hence of rare changing of default locale. Pages can be duplicated if you have locale extlang subtag like en-US and en-GB - will be almost identical. So search engines should recognize them as same text in different locales (I hope it'll be in future). There added parameters in configuration to setup redirect behavior. Separator hyphen kept (not underscore) due to () and ([http://en.wikipedia.org/wiki/IETF\_language\_tag](http://en.wikipedia.org/wiki/IETF_language_tag)) and () new standards. The default locale at '/' will do smoother adding locale in projects without locale.

BC changes:

- By enabling this module locales will be added to all http routes. To disable it add **'disable\_locale' =&gt; true,** parameter to custom route.

Using:

- Getting current locale by \\Locale::getDefault();
- Getting current locale alias by $this-&gt;params('locale'); in controller action. or by \\LibraLocale\\Module::$alias;
- Getting list of available and allowed aliases and locales by: \\LibraLocale\\Module::getLocales()

Added:
Flag *redirect\_from\_locale\_tag* that allow redirect from locale tag to alias. Now it will accept as alias that almost unknown. By default = false, but for BC it will be true in libra-cms globals until ver. 0.6.0.

To get proper links by navigation helper use type in page **LibraLocale\\Navigation\\Page\\Uri**and **LibraLocale\\Navigation\\Page\\Mvc**. Or use type of page === null and for service container - **LibraLocale\\Navigation\\Service\\DefaultNavigationFactory**. It can be done by adding in *application.config.php* file in 'service\_manager' array row:

```
            'Navigation' => 'LibraLocale\Navigation\Service\DefaultNavigationFactory',

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.9% 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 ~74 days

Recently: every ~16 days

Total

6

Last Release

4620d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c5ea80353eb117dbabb0def7d2a43079815acee0d55f690a6476c03e458c203?d=identicon)[joacub](/maintainers/joacub)

---

Top Contributors

[![vnagara](https://avatars.githubusercontent.com/u/1571419?v=4)](https://github.com/vnagara "vnagara (26 commits)")[![joacub](https://avatars.githubusercontent.com/u/2091228?v=4)](https://github.com/joacub "joacub (2 commits)")

---

Tags

cmsZendFrameworkzfzf2libra

### Embed Badge

![Health badge](/badges/joacub-libra-locale/health.svg)

```
[![Health](https://phpackages.com/badges/joacub-libra-locale/health.svg)](https://phpackages.com/packages/joacub-libra-locale)
```

###  Alternatives

[libra/libra-cms

ZF2 based CMS that allows easily create your own web-site with necessary tools like article menagment

231.2k](/packages/libra-libra-cms)

PHPackages © 2026

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