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

ActiveSymfony-bundle[Localization &amp; i18n](/categories/localization)

raindrop/locale-bundle
======================

Raindrop Locale Symfony2 Bundle

01.04.02(13y ago)3167MITPHPPHP &gt;=5.3.3

Since Feb 3Pushed 12y ago2 watchersCompare

[ Source](https://github.com/raindropdevs/RaindropLocaleBundle)[ Packagist](https://packagist.org/packages/raindrop/locale-bundle)[ Docs](https://github.com/raindropdevs)[ RSS](/packages/raindrop-locale-bundle/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (5)Versions (12)Used By (0)

Raindrop Locale Bundle
======================

[](#raindrop-locale-bundle)

[![Build Status](https://camo.githubusercontent.com/7772df08a50fe9f06a599d59b8a0c350a0e7046483c78755933599e004821a5e/68747470733a2f2f7472617669732d63692e6f72672f7261696e64726f70646576732f5261696e64726f704c6f63616c6542756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/raindropdevs/RaindropLocaleBundle)

This bundle is a fork of LuneticsLocaleBundle which allows you to guess the Locale from different parameters in your Symfony2 applications.

Installation
============

[](#installation)

### Add the package to your dependencies

[](#add-the-package-to-your-dependencies)

```
"require": {
    "raindrop/locale-bundle": "dev-master",
    ....
},
```

### Register the bundle in your kernel

[](#register-the-bundle-in-your-kernel)

```
public function registerBundles()
    {
        $bundles = array(
            // ...
            new Raindrop\LocaleBundle\RaindropLocaleBundle(),
        );
```

### Update your packages

[](#update-your-packages)

```
php composer.phar update raindrop/locale-bundle

```

Configuration
=============

[](#configuration)

### Allowed locales for your application

[](#allowed-locales-for-your-application)

You need to define at least one valid locale that is valid for your application

```
raindrop_locale:
  allowed_locales:
    - en
    - fr
    - de
```

#### Strict Mode

[](#strict-mode)

```
raindrop_locale:
  strict_mode: true # defaults to false
```

You can enable `strict_mode`, where only the **exact** allowed locales will be matched. For example:

- If your user has a browser locale with `de_DE` and `de`, and you only explicitly allow `de`, the locale `de` will be chosen.
- If your user has a browser locale with `de` and you only explicitly allow `de_DE`, no locale will be detected.

We encourage you to use the non-strict mode, that'll also choose the best region locale for your user.

### Guessers

[](#guessers)

You need to activate and define the order of the locale guessers. This is done in one step in the configuration :

```
raindrop_locale:
  guessing_order:
    - session
    - cookie
    - browser
    - query
    - router
```

With the example above, the guessers will be called in the order you defined as 1. session 2. cookie 2. router 3. browser.

Note that the session and cookie guessers only retrieve previously identified and saved locales by the router or browser guesser.

If you use the \_locale parameter as attribute/parameter in your routes, you should use the query and router guesser first.

```
raindrop_locale:
  guessing_order:
    - query
    - router
    - session
    - cookie
    - browser
```

### Locale Cookies / Session

[](#locale-cookies--session)

The session and cookie guesser is usually used when you do not use locales in the uri's and you guess it from the user browser preferences. When doing this,

it is good to set *session* and/or *cookie* as the first guesser to not try to detect the locale at each request.

#### Cookie

[](#cookie)

If you use the cookie guesser, it will be automatically read from the cookie and write changes into the cookie anytime the locale has changed (Even from another guesser)

```
raindrop_locale:
  cookie:
    set_on_change: true
```

This is most useful for unregistered and returning visitors.

#### Session

[](#session)

The session guesser will automatically save a previously identified locale into the session and retrieve it from the session. This guesser should always be first in your `guessing_order` configuration if you don't use the router guesser.

### FilterLocaleSwitchEvent / LocaleUpdateListener

[](#filterlocaleswitchevent--localeupdatelistener)

The `LocaleGuesserManager` dispatches a `LocaleBundleEvents::onLocalChange` if you use either the 'session' or `cookie` guesser. The LocaleUpdateListeners checks if the locale has changed and updates the session or cookie.

For example, if you don't use route / query parameters for locales, you could build an own listener for your user login, which dispatches a `LocaleBundleEvents::onLocalChange` event to set the locale for your user. You just have to use the `FilterLocaleSwitchEvent` and set the locale.

```
$locale = $user->getLocale();
$localeSwitchEvent = new FilterLocaleSwitchEvent($locale);
$this->dispatcher->dispatch(LocaleBundleEvents::onLocaleChange, $localeSwitchEvent);
```

### Custom Guessers

[](#custom-guessers)

Read more about creating your own guesser here:

[Read the full documentation for creating a custom Locale Guesser](Resources/doc/guesser.md)

### Switch to another locale

[](#switch-to-another-locale)

You can render a default locale switcher, simply by calling the twig function in your template :

```
{{ locale_switcher() }}
```

[Read the full documentation for the switcher](Resources/doc/switcher.md)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

9

Last Release

4826d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/192c7e913bae85210467fc766caf3a851944154e89aad9444a33b41d3bc323c6?d=identicon)[raindrop](/maintainers/raindrop)

---

Top Contributors

[![erivello](https://avatars.githubusercontent.com/u/626131?v=4)](https://github.com/erivello "erivello (40 commits)")

---

Tags

languagesessionlocalemultilanguagecookie

### Embed Badge

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

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

###  Alternatives

[lunetics/locale-bundle

A Bundle for switching Languages

1861.1M8](/packages/lunetics-locale-bundle)[lexik/translation-bundle

This bundle allows to import translation files content into the database and provide a GUI to edit translations.

4362.7M19](/packages/lexik-translation-bundle)[codezero/laravel-localizer

Automatically detect and set an app locale that matches your visitor's preference.

50394.3k4](/packages/codezero-laravel-localizer)[jms/translation-bundle

Puts the Symfony Translation Component on steroids

42510.8M63](/packages/jms-translation-bundle)[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[aplus/language

Aplus Framework Language Library

2351.7M15](/packages/aplus-language)

PHPackages © 2026

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