The Kunstmaan Language chooser bundle supplies your project with basic but extendible language chooser

Installs: 3 067

Dependents: 0

Stars: 6

Watchers: 36

Forks: 4

Type: symfony-bundle

3.4.1 2015-10-05 19:02 UTC


Build Status Total Downloads Latest Stable Version Analytics

Handles autodetection of the language of the end user or shows a splash page with a language choice.

Installation instructions

Assuming you have installed composer.phar or composer binary:

$ composer require kunstmaan/languagechooser-bundle dev-master

Add the KunstmaanLanguageChooserBundle and the LuneticsLocaleBundle to your AppKernel.php file:

new Kunstmaan\LanguageChooserBundle\KunstmaanLanguageChooserBundle(),
new Lunetics\LocaleBundle\LuneticsLocaleBundle(),

Remark: The KunstmaanLanguageChooserBundle should be loaded BEFORE the LuneticsLocaleBundle

Add the KunstmaanLanguageChooserBundle to your routing.yml:

# KunstmaanLanguageChooserBundle
    resource: .

Overwrite the KunstmaanLanguageChooserBundle config to your needs in config.yml:

    autodetectlanguage: false
    showlanguagechooser: true
    languagechoosertemplate: CompanyYourBundle:Default:language-chooser.html.twig
    languagechooserlocales: [en, nl, fr]


When the user arrives on the root page of your website (eg. http://domain.com/) he:

  • is automatically redirect to his language of choice (eg. http://domain.com/en) when the autodetectlanguage is set to true
  • sees a splash page where he can select his language manually when the showlanguagechooser is set to true

The template path of the splash page can we set via the languagechoosertemplate configuration parameter.

In all your Twig templates, there is a global variable available with an array of the available languages: languagechooser_languages. This can be usefull on your custom splash page, or when you want to show the language choice on other pages.

    {% for lang in languagechooser_languages %}
        <li>{{ lang }}</li>
    {% endfor %}