Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
add default language same as magento
Browse files Browse the repository at this point in the history
  • Loading branch information
blopa committed Dec 30, 2017
1 parent 15beb12 commit d84444c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
14 changes: 11 additions & 3 deletions Magento2/app/code/Werules/Chatbot/Block/Chatbox/Messenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -110,4 +113,9 @@ private function setConfigValue($field, $value)
{
$this->_helper->setConfigValue($field, $value);
}

public function getLocaleCode()
{
return $this->_store->getLocaleCode();
}
}
2 changes: 1 addition & 1 deletion Magento2/app/code/Werules/Chatbot/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="werules" sortOrder="10" translate="label comment tooltip">
<tab id="werules_chatbot" sortOrder="10" translate="label comment tooltip">
<label>Chatbot Integration</label>
</tab>
<section id="werules_chatbot_general" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="1" translate="label comment tooltip">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php
/**
* @var $block \Werules\Chatbot\Block\Chatbox\Messenger
*/
$locale = $this->getLocaleCode();
if (!$locale)
$locale = 'en_US'; // fallback
?>
<?php if ($this->isChatboxEnabled()): ?>
<script>
// Facebook SDK for JavaScript
Expand All @@ -14,7 +22,7 @@
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
js.src = "https://connect.facebook.net/<?php echo $locale ?>/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Expand Down

0 comments on commit d84444c

Please sign in to comment.