Je commence mon 1er projet et c'est le début des galères
J'ai une erreur de trad dans ma navbar, de ce que je comprend, il ne trouve pas mon local pourtant je l'ai mis dans mon routing.yaml je pense que j'ai mal config le tout si quelqu'un a le temps de m'aider
Merci d'avance !
Code : Tout sélectionner
//config.yml
translator:
fallbacks: ["%default_locale%"]
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
----------------------------------------------
// TranslationController
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Translation\Translator;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;
class TranslationController extends Controller
{
/**
* @param TranslatorInterface $translator
* @return Response
*/
public function indexAction(TranslatorInterface $translator)
{
$translator = new Translator('fr_FR');
$translator->addLoader('yaml', new YamlFileLoader());
$translator->addResource('yaml', 'path/to/messages.fr.yaml', 'fr_FR');
$translator->addResource('yaml', 'path/to/messages.en.yaml', 'en_EN');
return $this->render('base.html.twig');
}
}
----------------------------------------------
// base.html.twig
<li class="nav-item">
<a href="#intro" class="nav-link link-scroll">{{ 'navbar.intro'|trans }}</a>
</li>
// Error
These messages are not available for the given locale and cannot be found in the fallback locales. Add them to the translation catalogue to avoid Symfony outputting untranslated contents.
Locale Domain Times used Message ID Message Preview
fr messages 1 navbar.intro navbar.intro