-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from calien666/feature/support-api-languages
[FEATURE] add supported languages automatically from API
- Loading branch information
Showing
5 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
getenv('DEEPL_API_KEY') or die('Environment variable DEEPL_API_KEY is not set. Please set in local Context in ddev config.yaml'); | ||
|
||
return [ | ||
'EXTENSIONS' => [ | ||
'wv_deepltranslate' => [ | ||
'apiKey' => getenv('DEEPL_API_KEY') ?? '', | ||
'apiUrl' => 'https://api-free.deepl.com/v2/translate', | ||
'deeplFormality' => 'default', | ||
'googleapiKey' => '', | ||
'googleapiUrl' => 'https://translation.googleapis.com/language/translate/v2', | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Functional\Services; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
use WebVision\WvDeepltranslate\Service\DeeplService; | ||
|
||
class DeeplServiceTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
protected $testExtensionsToLoad = [ | ||
'typo3conf/ext/wv_deepltranslate', | ||
]; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->configurationToUseInTestInstance = array_merge( | ||
$this->configurationToUseInTestInstance, | ||
require __DIR__ . '/../Fixtures/ExtensionConfig.php' | ||
); | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->importDataSet(__DIR__ . '/../Fixtures/Settings.xml'); | ||
$this->importDataSet(__DIR__ . '/../Fixtures/Language.xml'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function checkSupportedLanguages(): void | ||
{ | ||
$deeplService = GeneralUtility::makeInstance(DeeplService::class); | ||
|
||
static::assertContains('EN-GB', $deeplService->apiSupportedLanguages); | ||
static::assertContains('EN-US', $deeplService->apiSupportedLanguages); | ||
static::assertContains('DE', $deeplService->apiSupportedLanguages); | ||
static::assertContains('UK', $deeplService->apiSupportedLanguages); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function checkFormalitySupportedLanguages(): void | ||
{ | ||
$deeplService = GeneralUtility::makeInstance(DeeplService::class); | ||
|
||
static::assertContains('ES', $deeplService->formalitySupportedLanguages); | ||
static::assertContains('DE', $deeplService->formalitySupportedLanguages); | ||
static::assertContains('NL', $deeplService->formalitySupportedLanguages); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters