PHPackages                             slm/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. [Localization &amp; i18n](/categories/localization)
4. /
5. slm/locale

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

slm/locale
==========

Automatic detection of locales for Laminas

1.2.0(1y ago)68264.6k↑13.2%34[3 PRs](https://github.com/basz/SlmLocale/pulls)3BSD-3-ClausePHPPHP ^7.2 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

Since May 19Pushed 1y ago16 watchersCompare

[ Source](https://github.com/basz/SlmLocale)[ Packagist](https://packagist.org/packages/slm/locale)[ Docs](https://github.com/juriansluiman/SlmLocale)[ RSS](/packages/slm-locale/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (19)Used By (3)

SlmLocale
=========

[](#slmlocale)

[![CI](https://github.com/basz/SlmLocale/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/basz/SlmLocale/actions/workflows/ci.yaml)[![Latest Stable Version](https://camo.githubusercontent.com/4c50ad6f1c500434c6f7a56f5c8c58e07ad43f4ae445a0d6ea0234e089a8db66/68747470733a2f2f706f7365722e707567782e6f72672f736c6d2f6c6f63616c652f762f737461626c652e706e67)](https://packagist.org/packages/slm/locale)[![Coverage Status](https://camo.githubusercontent.com/729d1586bef09c23752c63a8b490b4c691570700944dd3dc9f3c8d2d9817073d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6261737a2f536c6d4c6f63616c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/basz/SlmLocale?branch=master)

Created by Jurian Sluiman

Introduction
------------

[](#introduction)

SlmLocale is a Laminas module to automatically detect a locale for your application. It uses a variety of pluggable strategies to search for a valid locale. SlmLocale features a default locale, a set of supported locales and locale aliases.

SlmLocale supports out of the box several strategies to search for a locale. Through interfaces, other strategies could be created. The set of default stragies is:

1. The HTTP `Accept-Language` header
2. A cookie to store the locale between several sessions of one visitor
3. A query parameter to easily switch from locale
4. The first segment of the path of an uri
5. A part of the domain name (either the TLD or a subdomain)

Furthermore, it provides a set of additional localisation features:

1. A default locale, used as fallback
2. A set of aliases, so you can map `.com` as "en-US" in the host name strategy
3. Redirect to the right domain/path when a locale is found
4. View helpers to create a localised uri or a list of language switches

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

[](#installation)

Add "slm/locale" to your composer.json file and update your dependencies. Enable SlmLocale in your `application.config.php`.

If you do not have a composer.json file in the root of your project, copy the contents below and put that into a file called `composer.json` and save it in the root of your project:

```
{
    "require": {
        "slm/locale": ">=0.1.0,">

```

### Disable UriPathStrategy in PHPUNIT

[](#disable-uripathstrategy-in-phpunit)

This is necessary (at the moment) if you want to use `this->dispatch('my/uri');` in your `AbstractHttpControllerTestCase` unit tests. Otherwise, if you check for responseCode you will get `302` where it should be `200`.

Example:

```
$this->dispatch('/to/my/uri');
$this->assertResponseStatusCode(200); // this will be 302 instead of 200

$this->dispatch('/en/to/my/uri');
$this->assertResponseStatusCode(200); // this will be 302 instead of 200

```

To fix add the following to your phpunit config.

phpunit.xml:

```

    ...

```

Or set `$_SERVER['DISABLE_URIPATHSTRATEGY'] = true;` in your bootstrap file of phpunit.

### Create a list of available locales

[](#create-a-list-of-available-locales)

T.B.D

Read more about usage and the configuration of all the strategies in the [documentation](docs/1.Introduction.md).

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~297 days

Recently: every ~508 days

Total

15

Last Release

581d ago

Major Versions

v0.5.0 → 1.0.02022-11-21

PHP version history (7 changes)v0.0.1PHP &gt;=5.3.3.

v0.2.0PHP ^5.5 || ^7.0

v0.3.0PHP ^5.6 || ^7.0

v0.5.0PHP ^7.2

1.0.0PHP ^7.2 || ~8.0.0 || ~8.1.0

1.1.0PHP ^7.2 || ~8.0.0 || ~8.1.0 || ~8.2.0

1.2.0PHP ^7.2 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

### Community

Maintainers

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

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

![](https://www.gravatar.com/avatar/9e0ab73cb83a2ef230038f67af23225940abc7ae809817d52c8445b43710d4ed?d=identicon)[svycka](/maintainers/svycka)

---

Top Contributors

[![svycka](https://avatars.githubusercontent.com/u/1270782?v=4)](https://github.com/svycka "svycka (55 commits)")[![kokspflanze](https://avatars.githubusercontent.com/u/1885435?v=4)](https://github.com/kokspflanze "kokspflanze (42 commits)")[![basz](https://avatars.githubusercontent.com/u/143068?v=4)](https://github.com/basz "basz (38 commits)")[![fwwarr](https://avatars.githubusercontent.com/u/485106?v=4)](https://github.com/fwwarr "fwwarr (3 commits)")[![RWOverdijk](https://avatars.githubusercontent.com/u/781745?v=4)](https://github.com/RWOverdijk "RWOverdijk (3 commits)")[![swiftchase](https://avatars.githubusercontent.com/u/8070208?v=4)](https://github.com/swiftchase "swiftchase (2 commits)")[![demiankatz](https://avatars.githubusercontent.com/u/309069?v=4)](https://github.com/demiankatz "demiankatz (2 commits)")[![jroedel](https://avatars.githubusercontent.com/u/3315281?v=4)](https://github.com/jroedel "jroedel (2 commits)")[![prolic](https://avatars.githubusercontent.com/u/394428?v=4)](https://github.com/prolic "prolic (2 commits)")[![slavcodev](https://avatars.githubusercontent.com/u/757721?v=4)](https://github.com/slavcodev "slavcodev (1 commits)")[![sasezaki](https://avatars.githubusercontent.com/u/42755?v=4)](https://github.com/sasezaki "sasezaki (1 commits)")[![atukai](https://avatars.githubusercontent.com/u/308995?v=4)](https://github.com/atukai "atukai (1 commits)")

---

Tags

laminasi18nzflocaleZend Framework

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  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)[laminas/laminas-mvc

Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins

17224.4M365](/packages/laminas-laminas-mvc)[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)[laminas/laminas-mvc-i18n

Integration between laminas-mvc and laminas-i18n

144.5M44](/packages/laminas-laminas-mvc-i18n)[laminas/laminas-developer-tools

Module for developer and debug tools for use with laminas-mvc applications.

252.0M33](/packages/laminas-laminas-developer-tools)

PHPackages © 2026

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