Unverified Commit df359fd1 authored by Mathieu Ferment's avatar Mathieu Ferment Committed by GitHub
Browse files

Merge pull request #27766 from jolelievre/fix-multilang-translator-issue

Fix multilang translator issue
parents 7dbf4592 8a041a83
......@@ -34,6 +34,7 @@ use PrestaShopBundle\Install\Language as InstallLanguage;
use PrestaShopBundle\Translation\TranslatorComponent as Translator;
use PrestaShopBundle\Translation\TranslatorLanguageLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
......@@ -445,18 +446,26 @@ class ContextCore
try {
$containerFinder = new ContainerFinder($this);
->loadLanguage($translator, $locale, $withDB, $theme);
$container = $containerFinder->getContainer();
$translatorLoader = $container->get('prestashop.translation.translator_language_loader');
} catch (ContainerNotFoundException $exception) {
$translatorLoader = null;
} catch (ServiceNotFoundException $e) {
$translatorLoader = null;
if (null === $translatorLoader) {
// If a container is still not found, instantiate manually the translator loader
// This will happen in the Front as we have legacy controllers, the Sf container won't be available.
// As we get the translator in the controller's constructor and the container is built in the init method, we won't find it here
(new TranslatorLanguageLoader(new ModuleRepository()))
->loadLanguage($translator, $locale, $withDB, $theme);
$translatorLoader = (new TranslatorLanguageLoader(new ModuleRepository()));
->loadLanguage($translator, $locale, $withDB, $theme)
return $translator;
......@@ -30,12 +30,6 @@ ob_start();
require_once dirname(__FILE__) . '/../config/config.inc.php';
global $kernel;
if (null === $kernel) {
$kernel = new AppKernel(_PS_ENV_, _PS_MODE_DEV_);
// Cart is needed for some requests
Context::getContext()->cart = new Cart();
Context::getContext()->container = ContainerBuilder::getContainer('webservice', _PS_MODE_DEV_);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment