PHPackages                             sred/zf2languages - 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. sred/zf2languages

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

sred/zf2languages
=================

Open plugin for using multilanguage on ZF2 applications

3122PHP

Since Jul 31Pushed 10y ago1 watchersCompare

[ Source](https://github.com/danitome24/zf2-languages)[ Packagist](https://packagist.org/packages/sred/zf2languages)[ RSS](/packages/sred-zf2languages/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

License:
--------

[](#license)

zf2Languages: Open plugin for using multilanguage on ZF2 applications Copyright (C) 2015 SREd Servei de Recursos Educatius

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see .

Author:
-------

[](#author)

Daniel Tomé Fernández () as a worker on SREd ()

Introduction:
-------------

[](#introduction)

This plugin help us using multilanguage on our Zend Framework 2 application. It provides us an API and a config. This config will be fundamental for correct working.

Installation:
-------------

[](#installation)

To install this module you must follow this steps:

1 - In your `composer.json` you must write:

```
"require": {
        "sred/zf2languages" : "dev-master"
    },
```

```
and

```

```
"autoload": {
      "psr-4":{
         "zf2languages\\" : "vendor/sred/zf2languages"
      }
}
```

2 - Then you must run the following command line: `composer update`

Configuration:
--------------

[](#configuration)

To use this plugin you must make a config like the following:

```
'languages' => array(
        'all' => array(
            'ca' => 'Catalan',
            'es' => 'Spanish',
            'en' => 'English',
        ),
        'default' => array(
            'ca',
        ),
    ),
```

```
'browser' => array(
        'set_lang_from_browser' => true,
    ),
```

In `all` array you must have the key and the translation of this key. For example: 'en' =&gt; 'English'. In `default` language you must have the key of the default language. In `browser` array you must have defined if you want to get language from browser configuration or not.

And the last step is adding the module to your module's configuration `application.conf.php`:

```
    'modules' => array(
        'zf2languages',
    ),
```

Usage:
------

[](#usage)

It is very easy using this plugin. We provide a Helper and a Plugin so in the view or controllers you only must write : `$this->languages()->method()`.

If you want to use it out of view and controllers, we provide a Factory of Languages. So you only must write:

`$languages = $serviceManager->get('languages');` and you'll have all the functions available.

API provided:
-------------

[](#api-provided)

`isDefaultLanguage($lang)` -&gt; This method will return if parameter is equals to default language defined on config(key).

`getDefaultLanguage()` -&gt; This method will return the default language defined on our config file.

`getLanguagesCodes()` -&gt; This method will return the array defined on our config with the key 'all'. (keys and translations).

`translate($lang)` -&gt; Given a key of a language, this method will return the translation of that key.

`isValid($lang)` -&gt; Given a key this method will return if this language is defined or not.

`updateCookie($serviceManager, $lang)` -&gt; This method will help us to create a cookie with language defined on our application.

`getLocaleForSession($serviceManager)` -&gt; This method will give to us the language depending on the language on our browser or cookie.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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/2f7682b832dd991c83eed4f29cbd4257309dfcc2a672b306e61fafc1918d0236?d=identicon)[danitome24](/maintainers/danitome24)

### Embed Badge

![Health badge](/badges/sred-zf2languages/health.svg)

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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