Bonjour,
la traduction ne se fait pas ni fr ni en !!
DefaultControlleur:
1 2 3 4 5 6 7 8 9 10 11 12 13
| public function choisirLangueAction($langue = null){
if($langue != null)
{
$this->container->get('request')->setLocale($langue);
}
$url = $this->container->get('request')->headers->get('referer');
if (empty($url)) {
$url = $this->container->get('router')->generate('my_app_esprit_top');
}
return new \Symfony\Component\HttpFoundation\RedirectResponse($url);
} |
routing.yml
1 2 3 4 5 6
| myapp_choisir_langue:
pattern: /choisir-langue/{langue}
defaults: { _controller: MyAppEspritBundle:Default:choisirLangue }
my_app_esprit_top:
pattern: /index.php
defaults: { _controller: MyAppEspritBundle:Article:top } |
Config.yml
1 2 3 4
| framework:
#esi: ~
translator: { fallback: fr }
default_locale: fr |
layout
1 2
| <a href="{{ path('myapp_choisir_langue', {'langue' : 'fr'}) }}"><img src="{{ asset('bundles/myappesprit/images/flag 2.jpg') }}" alt="" class="middle" /></a>
<a href="{{ path('myapp_choisir_langue', {'langue' : 'en'}) }}"><img src="{{ asset('bundles/myappesprit/images/flag 1.jpg') }}" alt="" class="middle" /></a> |
messages.fr.yml (sous Resources/translations)
messages.en.yml (sous Resources/translations)
vue a traduire :
<li> <a href="#url">{{ rubrique.title|capitalize|trans }} </a>
merci d'avance .
Partager