From d84444cbc601982702cd304fe09c63ca4f41d8d7 Mon Sep 17 00:00:00 2001 From: blopa Date: Sat, 30 Dec 2017 00:26:17 -0200 Subject: [PATCH] add default language same as magento --- .../Werules/Chatbot/Block/Chatbox/Messenger.php | 14 +++++++++++--- .../code/Werules/Chatbot/etc/adminhtml/system.xml | 2 +- .../templates/chatbox/facebook_js_sdk.phtml | 10 +++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Magento2/app/code/Werules/Chatbot/Block/Chatbox/Messenger.php b/Magento2/app/code/Werules/Chatbot/Block/Chatbox/Messenger.php index 162271a..ae0352a 100644 --- a/Magento2/app/code/Werules/Chatbot/Block/Chatbox/Messenger.php +++ b/Magento2/app/code/Werules/Chatbot/Block/Chatbox/Messenger.php @@ -26,16 +26,19 @@ class Messenger extends \Magento\Framework\View\Element\Template protected $_helper; protected $_define; protected $_chatbotAPI; + protected $_store; public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Werules\Chatbot\Helper\Data $helperData, + \Magento\Store\Api\Data\StoreInterface $store, \Werules\Chatbot\Model\ChatbotAPI $chatbotAPI, array $data = array() ) { $this->_chatbotAPI = $chatbotAPI; $this->_helper = $helperData; + $this->_store = $store; $this->_define = new \Werules\Chatbot\Helper\Define; parent::__construct($context, $data); } @@ -71,7 +74,7 @@ public function getFacebookAppId() return $appId; } - public function isDomainWhitelabeled() + public function isDomainWhitelisted() { $enable = $this->getConfigValue('werules_chatbot_messenger/general/domain_whitelisted'); if ($enable) @@ -94,8 +97,8 @@ public function isDomainWhitelabeled() public function isChatboxEnabled() { $enable = $this->getConfigValue('werules_chatbot_messenger/general/enable_messenger_box'); - $isWhitelabeled = $this->isDomainWhitelabeled(); - if ($enable && $isWhitelabeled) + $isWhitelisted = $this->isDomainWhitelisted(); + if ($enable && $isWhitelisted) return true; return false; @@ -110,4 +113,9 @@ private function setConfigValue($field, $value) { $this->_helper->setConfigValue($field, $value); } + + public function getLocaleCode() + { + return $this->_store->getLocaleCode(); + } } diff --git a/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml b/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml index d71ead4..4e0ffad 100644 --- a/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml +++ b/Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml @@ -1,7 +1,7 @@ - +
diff --git a/Magento2/app/code/Werules/Chatbot/view/frontend/templates/chatbox/facebook_js_sdk.phtml b/Magento2/app/code/Werules/Chatbot/view/frontend/templates/chatbox/facebook_js_sdk.phtml index e9f7e4f..cc2b8b4 100644 --- a/Magento2/app/code/Werules/Chatbot/view/frontend/templates/chatbox/facebook_js_sdk.phtml +++ b/Magento2/app/code/Werules/Chatbot/view/frontend/templates/chatbox/facebook_js_sdk.phtml @@ -1,3 +1,11 @@ +getLocaleCode(); + if (!$locale) + $locale = 'en_US'; // fallback +?> isChatboxEnabled()): ?>