PHPackages                             fabiang/laminas-language-route - 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. fabiang/laminas-language-route

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

fabiang/laminas-language-route
==============================

Adds language prefix to every route

v2.2.0(3mo ago)21.0k1GPL-2.0-onlyPHPPHP &gt;=8.1,&lt;8.6CI passing

Since Mar 11Pushed 3mo agoCompare

[ Source](https://github.com/fabiang/laminas-language-route)[ Packagist](https://packagist.org/packages/fabiang/laminas-language-route)[ RSS](/packages/fabiang-laminas-language-route/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (12)Versions (6)Used By (0)

Language Route for Laminas
==========================

[](#language-route-for-laminas)

Modue that adds a language to the beginning of every route and sets the selected language in the MvcTranslator.

[![Latest Stable Version](https://camo.githubusercontent.com/f8402becd95ee58b0796b43d10622e1c0cd42a9b64c195f3257273610cfb9a20/687474703a2f2f706f7365722e707567782e6f72672f66616269616e672f6c616d696e61732d6c616e67756167652d726f7574652f76)](https://packagist.org/packages/fabiang/laminas-language-route)[![PHP Version Require](https://camo.githubusercontent.com/c26b7dbb76e315bec456e12c2b5f9f03ea32ca476051a2370ce8aef68b0f598b/687474703a2f2f706f7365722e707567782e6f72672f66616269616e672f6c616d696e61732d6c616e67756167652d726f7574652f726571756972652f706870)](https://packagist.org/packages/fabiang/laminas-language-route)[![License](https://camo.githubusercontent.com/98a60cf161efbb2c5af51e564d8067b919a76b56fc1ade9e81b73108efa8cdc5/687474703a2f2f706f7365722e707567782e6f72672f66616269616e672f6c616d696e61732d6c616e67756167652d726f7574652f6c6963656e7365)](https://packagist.org/packages/fabiang/laminas-language-route)[![Continuous Integration](https://github.com/fabiang/laminas-language-route/actions/workflows/ci.yml/badge.svg)](https://github.com/fabiang/laminas-language-route/actions/workflows/ci.yml)

Installation
------------

[](#installation)

Installation of LanguageRoute uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

```
composer require fabiang/laminas-language-route
```

Then add `Fabiang\LaminasLanguageRoute` to your `config/application.config.php`

To display the language switch you will need the [usrz/bootstrap-languages](https://github.com/usrz/bootstrap-languages) package. Add the languages.css to your stylesheets and place the languages.png in the same folder.

Configuration
-------------

[](#configuration)

You can configure which prefix belongs to which language. For this, copy the config/laminas-language-route.global.php into your config/autoload folder and edit the array. It should have the same order as your MvcTranslator configuration to correctly guess the default language.

You can also change the default route name that is used to switched the language on a page with no RouteMatch instance (like 404).

Usage
-----

[](#usage)

After installation the router will automatically add the language before any assembled URL. It will also inject the 'locale' parameter into any RouteMatch instance. To read it you can use the following example code inside any Controller

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

The router will also check if the locale parameter is provided when assembling a route. Use it to force a specific language prefix:

```
$this->url()->fromRoute('home', ['locale' => 'de_DE']); // will point to /de
$this->url()->fromRoute('home', ['locale' => 'en_US']); // will point to /en
```

### Language Switch

[](#language-switch)

The languageSwitch ViewHelper is able to render a simple dropdown to change the current language. It tries to stay on the same page. If a 404 error is generated, it will link to the `home` route. You can adjust the home route via configuration. Sample usage:

```
echo $this->languageSwitch($renderMode, $currentLocale, $options);
```

All arguments are optional.

The helper has four different rendering modes:

- `LanguageSwitch::RENDER_TYPE_LIST_ITEM` (default): Bootstrap navigation dropdown list item
- `LanguageSwitch::RENDER_TYPE_NAVBAR`: Full Bootstrap navbar list with dropdown list item inside
- `LanguageSwitch::RENDER_TYPE_DIV`: DIV container with div elements for each option
- `LanguageSwitch::RENDER_TYPE_SELECT`: Select form element
- `LanguageSwitch::RENDER_TYPE_PARTIAL`: Custom partial ViewScript

You can pass options as array to modify classes output classes and other things. Please check the implementation for details about options.

Licence
-------

[](#licence)

Copyright (C) 2016 schurix, 2022 Fabian Grutschus

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 2 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, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance82

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 61.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 ~713 days

Total

3

Last Release

96d ago

PHP version history (3 changes)v2.0.0PHP ^7.4 || 8.0.\* || 8.1.\*

v2.1.0PHP ^7.4 || 8.0.\* || 8.1.\* || ~8.2.0 || ~8.3.0

v2.2.0PHP &gt;=8.1,&lt;8.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/a001be2e312db9f65923d77f79e8e94e659963fb9e5b19c766c90ddb7e0c3dd0?d=identicon)[fabiang](/maintainers/fabiang)

---

Top Contributors

[![xelax90](https://avatars.githubusercontent.com/u/1559538?v=4)](https://github.com/xelax90 "xelax90 (8 commits)")[![fabiang](https://avatars.githubusercontent.com/u/348344?v=4)](https://github.com/fabiang "fabiang (4 commits)")[![f-E-T](https://avatars.githubusercontent.com/u/87535893?v=4)](https://github.com/f-E-T "f-E-T (1 commits)")

---

Tags

laminaslaminas-modulelaminas-mvcphp

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fabiang-laminas-language-route/health.svg)

```
[![Health](https://phpackages.com/badges/fabiang-laminas-language-route/health.svg)](https://phpackages.com/packages/fabiang-laminas-language-route)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M293](/packages/doctrine-doctrine-orm-module)[rwoverdijk/assetmanager

An assetmanager module for Laminas.

2142.1M49](/packages/rwoverdijk-assetmanager)[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1076.9M130](/packages/laminas-laminas-cache)[slm/locale

Automatic detection of locales for Laminas

68264.6k4](/packages/slm-locale)

PHPackages © 2026

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