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

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

joacub/locale
=============

Automatic detection of locales for Zend Framework 2

v0.1.0(10y ago)039BSD-3-ClausePHPPHP &gt;=5.3.3.

Since Nov 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/joacub/SlmLocale)[ Packagist](https://packagist.org/packages/joacub/locale)[ Docs](https://github.com/juriansluiman/SlmLocale)[ RSS](/packages/joacub-locale/feed)WikiDiscussions master Synced 3w ago

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

SlmLocale
=========

[](#slmlocale)

[![Build Status](https://camo.githubusercontent.com/c2fecce4bac0e81b7f4d4f019b9be8e5455366eeb2e57709c9730fae4a9b0af0/68747470733a2f2f7472617669732d63692e6f72672f6a757269616e736c75696d616e2f536c6d4c6f63616c652e706e67)](https://travis-ci.org/juriansluiman/SlmLocale)[![Latest Stable Version](https://camo.githubusercontent.com/4c50ad6f1c500434c6f7a56f5c8c58e07ad43f4ae445a0d6ea0234e089a8db66/68747470733a2f2f706f7365722e707567782e6f72672f736c6d2f6c6f63616c652f762f737461626c652e706e67)](https://packagist.org/packages/slm/locale)

Created by Jurian Sluiman

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

[](#introduction)

SlmLocale is a Zend Framework 2 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,
