Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for setting locale #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Block/Widget/Flow.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ class Flow extends \Itonomy\Flowbox\Block\Base implements \Magento\Widget\Block\

private \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder;

private \Magento\Framework\Locale\Resolver $store;

/**
* Flow constructor.
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
* @param \Magento\Cookie\Helper\Cookie $cookie
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Encryption\EncryptorInterface $store
* @param array $data
*/
public function __construct(
Expand All @@ -30,11 +33,13 @@ public function __construct(
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
\Magento\Cookie\Helper\Cookie $cookie,
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Magento\Framework\Locale\Resolver $store,
array $data = []
) {
parent::__construct($context, $cookie, $encryptor, $data);
$this->productRepository = $productRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->_store = $store;
}

/**
Expand All @@ -50,7 +55,7 @@ protected function prepareConfig(): void
'flow' => $flow,
'key' => $this->escapeHtml((string) $this->getData('key')),
'lazyload' => (bool) $this->getData('lazyload'),
'locale' => (string) $this->pageConfig->getElementAttribute('html', 'lang')
'locale' => (string) $this->getData('locale') ?: $this->_store->getLocale()
];

if ($flow === static::FLOW_TYPE_DYNAMIC_PRODUCT) {
Expand Down
8 changes: 8 additions & 0 deletions etc/widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<description translate="true">Visit <![CDATA[<a href="https://app.getflowbox.com/login">flowbox</a>]]> to access your flows.</description>
</parameter>

<parameter name="locale" xsi:type="text" required="false" visible="true" sort_order="25">
<label translate="true">Locale</label>
<description translate="true"><![CDATA[
If left empty the <a href="https://docs.magento.com/user-guide/configuration/general/general.html#locale-options">Magento store locale</a> will be used. <br />
Visit <a href="https://help.getflowbox.com/en/articles/4485750-changing-the-language-region-of-your-flow#our-supported-locales">here</a> to see a list of supported locales.
]]></description>
</parameter>

<parameter name="lazyload" xsi:type="select" required="false" visible="true" sort_order="99">
<label translate="true">Enable Lazy Loading</label>
<options>
Expand Down