juanber84 / simplei18nbundle
This Bundle provides a simple solution for translations in Symfony2.
Package info
github.com/juanber84/Simplei18nBundle
Type:symfony-bundle
pkg:composer/juanber84/simplei18nbundle
dev-master
2014-03-18 08:32 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: >=2.0.0
This package is not auto-updated.
Last update: 2026-03-10 14:26:30 UTC
README
###Install with composer
{
"require": {
"juanber84/simplei18nbundle": "dev-master"
}
}
Compatible with http://symfony.com/doc/current/cookbook/session/locale_sticky_session.html
Add in your app/AppKernel.php
<?php // app/AppKernel.php public function registerBundles() { return array( // ... new Juanber84\Bundle\Simplei18nBundle\Juanber84Simplei18nBundle(), // ... ); }
Add in your app/routing.yml
juanber84_simplei18n:
resource: "@Juanber84Simplei18nBundle/Resources/config/routing.yml"
prefix: /
###Use it
Put the next twig code in the header of your layout:
{{ language('es') }} // If you used this it will convert to the language which you've inserted
{{ language() }} // If you used this it will convert to the language which _locale var session
Use the widget where you would show it:
{{ simplei18n(['es', 'en', 'pt', 'it'] )|raw }}
Make your custom widget using the path:
{{ path('juanber84_simplei18n_changelocale', {'locale': 'es'}) }}