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

Commit

Permalink
Merge pull request #40 from Baby-Markt/DEEP-7-deprecate-library
Browse files Browse the repository at this point in the history
DEEP-7: Final realease
  • Loading branch information
githubwnk authored May 24, 2022
2 parents e2ff8b3 + ae952c7 commit f3c3249
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 81 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ matrix:
- php: 7.3
- php: 7.4
- php: 8.0
- php: 8.1
- php: nightly
allow_failures:
- php: nightly
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [4.0.0] - 2022-**-05
### Added
- marked Package as abandoned
- PHP 8.1 compatibility
- glossary_id to translate-method
- ability to run Integration-Tests against custom host if needed (Free/Pro)
### Changed
- migrated phpunit.xml.dist
- fixed some Tests and general Maintenance such as Typos in README.md
- **Breaking Change!** standard DEEPL_HOST to free again
- **Breaking Change!** default source Langauge form DE to empty so DeepL will decide
### Removed

## [3.0.1] - 2021-07-09
### Added
### Changed
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The MIT License (MIT)

Copyright (c) 2019 babymarkt.de GmbH <[email protected]>
Copyright (c) 2018-2022 babymarkt.de GmbH <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# deepl-php-lib
***
## Deprecated Library !

Hello everyone,

in the last couple of months we didn't give much attention to this projekt. DeepL on the other hand has developed client libraries for Python, .NET and Node.js (see: [API-Doc][link-deepl-client-libraries]).

Since there is a PHP-Library in the works [Github][link-deepl-php-lib-github] and our track record with maintaining our library hasn't been as good as it should have been, we decided to abandon this library and switch internally to the official one.

To make clear that we won't continue to work on this repository, we will archive it. If anyone from the community wants to continue our work we can put a line in the README to point to the new maintained repository.

Otherwise, we recommend you to check out the new library coming from [DeepL][link-deepl-php-lib-github].

Thank you to everyone who contributed to this project over the years.

***
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
Expand Down Expand Up @@ -39,7 +54,7 @@ Use the DeepL API Pro:
use \BabyMarkt\DeepL\DeepL;

$authKey = '<AUTH KEY>';
$deepl = new DeepL($authKey,2,'api.deepl.com');
$deepl = new DeepL($authKey,2,'api-free.deepl.com');
```

### Translate
Expand Down Expand Up @@ -69,7 +84,7 @@ foreach ($translations as $translation) {
| param | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $text | Text to be translated. Only UTF8-encoded plain text is supported. The parameter may be specified as an Array and translations are returned in the same order as they are requested. Each of the array values may contain multiple sentences. Up to 50 texts can be sent for translation in one request. |
| $sourceLang | Language of the text to be translated. <br>default: de |
| $sourceLang | Language of the text to be translated. <br>default: "" (DeepL will auto-detect) |
| $targetLang | The language into which the text should be translated. <br> default: en |
| $tagHandling | Sets which kind of tags should be handled. Options currently available: "xml" |
| $ignoreTags | Array of XML tags that indicate text not to be translated. <br> default: null |
Expand Down Expand Up @@ -123,21 +138,21 @@ Create a glossary
$glossary = $deepl->createGlossary('MyGlossary', ['Hallo' => 'Hello'], 'de', 'en');
```

| param | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $name | Glossary name
| $entries | Array of entries
| $sourceLanguage | The source language into which the glossary rule apply |
| $targetLanguage | The target language into which the glossary rule apply |
| param | Description |
|-----------------|--------------------------------------------------------|
| $name | Glossary name |
| $entries | Array of entries |
| $sourceLanguage | The source language into which the glossary rule apply |
| $targetLanguage | The target language into which the glossary rule apply |

Delete a glossary
```php
$glossary = $deepl->deleteGlossary($glossaryId);
```

| param | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $glossaryId | Glossary uuid (set by DeepL when glossary is created)
| param | Description |
|-------------|-------------------------------------------------------|
| $glossaryId | Glossary uuid (set by DeepL when glossary is created) |

List glossaries
```php
Expand All @@ -157,9 +172,9 @@ $glossaryInformation = $deepl->glossaryInformation($glossaryId);
var_dump($glossaryInformation);
```

| param | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $glossaryId | Glossary uuid (set by DeepL when glossary is created)
| param | Description |
|-------------|-------------------------------------------------------|
| $glossaryId | Glossary uuid (set by DeepL when glossary is created) |

Get glossary entries
```php
Expand All @@ -169,9 +184,9 @@ foreach ($entries as $sourceLangText => $targetLangText) {
}
```

| param | Description |
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| $glossaryId | Glossary uuid (set by DeepL when glossary is created)
| param | Description |
|-------------|-------------------------------------------------------|
| $glossaryId | Glossary uuid (set by DeepL when glossary is created) |

### Configuring cURL requests
If you need to use a proxy, you can configure the underlying curl client to use one. You can also specify a timeout to avoid waiting for several minutes if Deepl is unreachable
Expand Down Expand Up @@ -231,3 +246,5 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
[link-author]: https://github.com/Baby-Markt
[link-contributors]: ../../contributors
[link-deepl]: https://www.deepl.com/docs-api/introduction/
[link-deepl-client-libraries]:https://www.deepl.com/en/docs-api/accessing-the-api/client-libraries/
[link-deepl-php-lib-github]:https://github.com/DeepLcom/deepl-php
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"abandoned": "deeplcom/deepl-php",
"name": "babymarkt/deepl-php-lib",
"type": "library",
"description": "DeepL API Client Library supporting PHP >= 7.3 && PHP < 8.1",
"description": "DeepL API Client Library supporting PHP >= 7.3 && PHP <= 8.1",
"keywords": [
"babymarkt",
"deepl",
Expand All @@ -19,7 +20,7 @@
}
],
"require": {
"php": ">=7.3 <8.1",
"php": ">=7.3 <8.2",
"ext-json": "*",
"ext-curl": "*"
},
Expand Down
34 changes: 16 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true">
<testsuites>
<testsuite name="DeepL Library Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/clover.xml" />
</logging>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="DeepL Library Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ final class Client implements ClientInterface
* @param integer $apiVersion
* @param string $host
*/
public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com')
public function __construct($authKey, $apiVersion = 2, $host = 'api-free.deepl.com')
{
$this->authKey = $authKey;
$this->apiVersion = $apiVersion;
Expand Down Expand Up @@ -215,7 +215,7 @@ public function buildQuery($paramsArray)
}
}

$body = http_build_query($paramsArray, null, '&');
$body = http_build_query($paramsArray, '', '&');

if (isset($textString)) {
$body = $textString . '&' . $body;
Expand Down
11 changes: 6 additions & 5 deletions src/DeepL.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

/**
* DeepL API client library
*
* @package BabyMarkt\DeepL
*/
class DeepL
{
Expand All @@ -26,7 +24,7 @@ class DeepL
*/
private $client;

public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com', ClientInterface $client = null)
public function __construct($authKey, $apiVersion = 2, $host = 'api-free.deepl.com', ClientInterface $client = null)
{
$this->client = $client ?? new Client($authKey, $apiVersion, $host);
}
Expand Down Expand Up @@ -64,6 +62,7 @@ public function languages($type = null)
* @param array|null $nonSplittingTags
* @param null $outlineDetection
* @param array|null $splittingTags
* @param string|null $glossaryId
*
* @return array
*
Expand All @@ -73,7 +72,7 @@ public function languages($type = null)
*/
public function translate(
$text,
$sourceLang = 'de',
$sourceLang = '',
$targetLang = 'en',
$tagHandling = null,
array $ignoreTags = null,
Expand All @@ -82,7 +81,8 @@ public function translate(
$preserveFormatting = null,
array $nonSplittingTags = null,
$outlineDetection = null,
array $splittingTags = null
array $splittingTags = null,
string $glossaryId = null
) {
if (is_array($tagHandling)) {
throw new InvalidArgumentException('$tagHandling must be of type String in V2 of DeepLLibrary');
Expand All @@ -99,6 +99,7 @@ public function translate(
'split_sentences' => $splitSentences,
'preserve_formatting' => $preserveFormatting,
'outline_detection' => $outlineDetection,
'glossary_id' => $glossaryId
);

$paramsArray = $this->removeEmptyParams($paramsArray);
Expand Down
2 changes: 1 addition & 1 deletion src/Glossary.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Glossary
* @param string $host
* @param ClientInterface|null $client
*/
public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com', ClientInterface $client = null)
public function __construct($authKey, $apiVersion = 2, $host = 'api-free.deepl.com', ClientInterface $client = null)
{
$this->client = $client ?? new Client($authKey, $apiVersion, $host);
}
Expand Down
Loading

0 comments on commit f3c3249

Please sign in to comment.