kunstmaan / languagechooser-bundle
The Kunstmaan Language chooser bundle supplies your project with basic but extendible language chooser
Installs: 3 464
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 39
Forks: 3
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.4.0
- lunetics/locale-bundle: ~2.0
- symfony/symfony: ~2.3
- dev-master / 4.0.x-dev
- 4.0.0-RC1
- 3.5.x-dev
- 3.5.1
- 3.5.0
- 3.4.x-dev
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.x-dev
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.x-dev
- 3.2.6
- 3.2.5
- 3.2.4.1
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1.1
- 3.2.1
- 3.2.0
- 3.1.x-dev
- 3.1.4
- 3.1.3
- v2.3.2
- v2.3.1
- v2.3.0
- dev-revert-1243-hotfix/generator-translations
- dev-sf3
- dev-fix-sensiolabs-insight
This package is auto-updated.
Last update: 2024-11-29 04:14:18 UTC
README
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 _languagechooser: resource: .
Overwrite the KunstmaanLanguageChooserBundle config to your needs in config.yml:
kunstmaan_language_chooser: autodetectlanguage: false showlanguagechooser: true languagechoosertemplate: CompanyYourBundle:Default:language-chooser.html.twig languagechooserlocales: [en, nl, fr]
Usage
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 totrue
- sees a splash page where he can select his language manually when the
showlanguagechooser
is set totrue
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.
<ul>
{% for lang in languagechooser_languages %}
<li>{{ lang }}</li>
{% endfor %}
</ul>