カスタムリスナーを登録することでこれを修正しました
namespace XXX;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class LocaleListener implements EventSubscriberInterface
{
private $defaultLocale;
public function __construct($defaultLocale = 'en')
{
$this->defaultLocale = $defaultLocale;
}
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
if (!$request->hasPreviousSession()) {
return;
}
if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->set('_locale', $request->getLocale());
} else {
$request->setDefaultLocale($request->getSession()->get('_locale', $this->defaultLocale));
}
}
static public function getSubscribedEvents()
{
return array(
// must be registered before the default Locale listener
KernelEvents::REQUEST => array(array('onKernelRequest', 17)),
);
}
}
その後変更
$request->setDefaultLocale($request->getSession()->get('_locale', $this->defaultLocale));
に
$request->setLocale($request->getSession()->get('_locale'));
と使用
$this->getRequest()->getSession()->set('_locale', 'nl');
ロケールを設定するために、翻訳と翻訳対象が機能するようになりました
これが他の誰かにも役立つことを願っています..