Skip to content

Commit

Permalink
FEATURE: add support of free API Deepl license
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainraye committed May 7, 2021
1 parent 4a8b9f2 commit 774eea0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Command/TranslationExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public function configure()
null,
InputOption::VALUE_OPTIONAL,
'Deepl API Dev Key. API key is looked up 1) at the Oro Config, 2) via the cli parameter, 3) into the var/deepl-license.key'
)->addOption(
'free-license',
null,
InputOption::VALUE_NONE,
'if you use the free license API of Deepl'
)->addOption(
'disable-deepl',
'd',
Expand Down Expand Up @@ -183,7 +188,7 @@ public function execute(InputInterface $input, OutputInterface $output)
}

if ($simulate) {
// $output->writeln($translation['key'] . ': ' . $translation['englishValue']);
// $output->writeln($translation['key'] . ': ' . $translation['englishValue']);
$totalChars += (int) mb_strlen($translation['englishValue']);
}

Expand Down Expand Up @@ -355,11 +360,12 @@ private function initDeepl(InputInterface $input): void
{
if (!$input->getOption('disable-deepl') && !$input->getOption('simulate')) {
$apiKey = $this->getDeeplApiKey($input);
$endpointUrl = $input->getOption('free-license') ? 'api-free.deepl.com' : 'api.deepl.com';

if (empty($apiKey)) {
throw new \Exception('DeepL API Key not defined. Please, go to OroPlatform Backoffice, menu System > Configuration > System Configuration > Integrations > DeepL. Or provide the key by the parameter "deepl-api-key" or set the key into the var/deepl-license.key file.');
} else {
$this->deepl = new DeepL($apiKey);
$this->deepl = new DeepL($apiKey, 2, $endpointUrl);
}
}
}
Expand Down

0 comments on commit 774eea0

Please sign in to comment.