Skip to content

Commit

Permalink
CC-28482: Fixed Backoffice and Marketplace translations. (#10290)
Browse files Browse the repository at this point in the history
CC-28482 Fixed Backoffice and Marketplace translations
  • Loading branch information
artem-png authored Jul 11, 2023
1 parent 15f14d4 commit 71be6de
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Spryker\Zed\Locale\Communication;

use Spryker\Shared\Kernel\Store;
use Spryker\Shared\LocaleExtension\Dependency\Plugin\LocalePluginInterface;
use Spryker\Zed\Kernel\Communication\AbstractCommunicationFactory;
use Spryker\Zed\Locale\Dependency\Facade\LocaleToStoreFacadeInterface;
Expand Down Expand Up @@ -35,4 +36,14 @@ public function getStoreFacade(): LocaleToStoreFacadeInterface
{
return $this->getProvidedDependency(LocaleDependencyProvider::FACADE_STORE);
}

/**
* @deprecated Will be removed after dynamic multi-store is always enabled.
*
* @return \Spryker\Shared\Kernel\Store
*/
public function getStore(): Store
{
return $this->getProvidedDependency(LocaleDependencyProvider::STORE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,28 @@ public function provide(ContainerInterface $container): ContainerInterface
$container->set(static::BC_FEATURE_FLAG_LOCALE_LISTENER, false);
$container->set(static::SERVICE_LOCALE, function (ContainerInterface $container): string {
$localeTransfer = $this->getFactory()->getLocalePlugin()->getLocaleTransfer($container);
$localeName = $localeTransfer->getLocaleNameOrFail();
$this->setStoreCurrentLocale($localeName);

return $localeTransfer->getLocaleNameOrFail();
return $localeName;
});

return $container;
}

/**
* @deprecated Will be removed after dynamic multi-store is always enabled.
*
* @param string $localeName
*
* @return void
*/
protected function setStoreCurrentLocale(string $localeName): void
{
if ($this->getFactory()->getStoreFacade()->isDynamicStoreEnabled()) {
return;
}

$this->getFactory()->getStore()->setCurrentLocale($localeName);
}
}
35 changes: 35 additions & 0 deletions src/Spryker/Zed/Locale/LocaleDependencyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Spryker\Zed\Locale;

use Orm\Zed\Store\Persistence\SpyStoreQuery;
use Spryker\Shared\Kernel\Store;
use Spryker\Shared\LocaleExtension\Dependency\Plugin\LocalePluginInterface;
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
use Spryker\Zed\Kernel\Container;
Expand Down Expand Up @@ -39,6 +40,13 @@ class LocaleDependencyProvider extends AbstractBundleDependencyProvider
*/
public const PROPEL_QUERY_STORE = 'PROPEL_QUERY_STORE';

/**
* @deprecated Will be removed after dynamic multi-store is always enabled.
*
* @var string
*/
public const STORE = 'STORE';

/**
* @var string
*/
Expand All @@ -53,6 +61,7 @@ public function provideCommunicationLayerDependencies(Container $container): Con
{
$container = $this->addLocalePlugin($container);
$container = $this->addStoreFacade($container);
$container = $this->addStore($container);

return $container;
}
Expand Down Expand Up @@ -140,6 +149,32 @@ protected function addCurrentLocale(Container $container): Container
return $container;
}

/**
* @deprecated Exists for BC-reasons only.
*
* @param \Spryker\Zed\Kernel\Container $container
*
* @return \Spryker\Zed\Kernel\Container
*/
protected function addStore(Container $container): Container
{
$container->set(static::STORE, function () {
return $this->getStore();
});

return $container;
}

/**
* @deprecated Exists for BC-reasons only.
*
* @return \Spryker\Shared\Kernel\Store
*/
protected function getStore(): Store
{
return Store::getInstance();
}

/**
* @param \Spryker\Zed\Kernel\Container $container
*
Expand Down

0 comments on commit 71be6de

Please sign in to comment.