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

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

rezzza/locale-voter-bundle
==========================

Fetch locale of project through voters

7111PHP

Since Nov 20Pushed 13y ago1 watchersCompare

[ Source](https://github.com/rezzza/LocaleVoterBundle)[ Packagist](https://packagist.org/packages/rezzza/locale-voter-bundle)[ RSS](/packages/rezzza-locale-voter-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

LocaleVoterBundle
=================

[](#localevoterbundle)

DEPRECATED
==========

[](#deprecated)

Use [LocaleBundle](https://github.com/lunetics/LocaleBundle) instead.
=====================================================================

[](#use-localebundle-instead)

Fetch locale of project through voters.

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

[](#installation)

Using composer:

```
    "rezzza/locale-voter-bundle": "1.0.*",
```

Then

```
composer update "rezzza/locale-voter-bundle"

```

Add on you AppKernel:

```
    $bundles = array(
        ...
        new Rezzza\LocaleVoterBundle\RezzzaLocaleVoterBundle(),
        ...
    )

```

Define configuration on your config.yml:

```
rezzza_locale_voter:
    strategy: request        # only one strategy available, you can set null to manually decide of locale.
    default_locale: %locale% # set fallback locale.
    locales: ['en', 'fr']    # Define valid locales.
    voters:                  # A list of voter. Order define priority.
        - rezzza.locale_voter.request_parameter.voter
        - rezzza.locale_voter.accept_language.voter
```

Usage
=====

[](#usage)

With default configuration defined above, it'll look at `_locale` GET parameter in first time, if it does not match, it will look at accept language headers. `locale` voted (defined on voters on default) will be setted on request.

You can easily define new voters or define your own strategy.

Write a Voter
=============

[](#write-a-voter)

You have just to inherit from `VoterInterface` and add the service id of the voter on the configuration.

Example of voter:

```
