diff --git a/Controller/PlatformUIController.php b/Controller/PlatformUIController.php index 8f9bbf1f..b2b5341a 100644 --- a/Controller/PlatformUIController.php +++ b/Controller/PlatformUIController.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Translation\TranslatorInterface; class PlatformUIController extends Controller { @@ -28,20 +29,28 @@ class PlatformUIController extends Controller /** @var int */ private $comboCacheTtl; - public function __construct(Provider $configAggregator, Loader $loader, $comboCacheTtl = 0) + /** @var \Symfony\Component\Translation\TranslatorInterface */ + private $translator; + + public function __construct(Provider $configAggregator, Loader $loader, TranslatorInterface $translator, $comboCacheTtl = 0) { $this->configAggregator = $configAggregator; $this->loader = $loader; + $this->translator = $translator; $this->comboCacheTtl = $comboCacheTtl; } /** * Renders the "shell" page to run the JavaScript application. * + * @param \Symfony\Component\HttpFoundation\Request $request + * * @return \Symfony\Component\HttpFoundation\Response */ - public function shellAction() + public function shellAction(Request $request) { + $this->translator->setLocale($request->getPreferredLanguage() ?: $request->getDefaultLocale()); + return $this->render( 'eZPlatformUIBundle:PlatformUI:shell.html.twig', ['parameters' => $this->configAggregator->getConfig()] diff --git a/Resources/config/services.yml b/Resources/config/services.yml index e3bf0df4..69eee202 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -75,6 +75,7 @@ services: arguments: - "@ezsystems.platformui.application_config.aggregator" - "@ezsystems.platformui.loader.combo_loader" + - "@translator" - "@=container.getParameter('kernel.debug') ? 0 : parameter('ezsystems.platformui.application_config.combo_loader.cache_ttl')" parent: ezsystems.platformui.controller.base