Skip to content

Commit

Permalink
Merge pull request web-vision#331 from web-vision/deepl-proxy-config
Browse files Browse the repository at this point in the history
[BUGFIX] Use TYPO3 configured proxy for deepl client
  • Loading branch information
NarkNiro authored May 23, 2024
2 parents 61bdf78 + 587daf6 commit 28e04b4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Classes/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace WebVision\WvDeepltranslate;

use DeepL\Translator;
use DeepL\TranslatorOptions;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WebVision\WvDeepltranslate\Exception\ApiKeyNotSetException;
Expand Down Expand Up @@ -43,7 +44,16 @@ protected function getTranslator(): Translator
throw new ApiKeyNotSetException('The api key ist not set', 1708081233823);
}

$this->translator = GeneralUtility::makeInstance(Translator::class, $this->configuration->getApiKey());
$options = [];
if (
isset($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'])
&& $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'] !== ''
&& GeneralUtility::isValidUrl($GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'])
) {
$options[TranslatorOptions::PROXY] = $GLOBALS['TYPO3_CONF_VARS']['HTTP']['proxy'];
}

$this->translator = new Translator($this->configuration->getApiKey(), $options);

return $this->translator;
}
Expand Down

0 comments on commit 28e04b4

Please sign in to comment.