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

Commit f3c3249

Browse files
authored
Merge pull request #40 from Baby-Markt/DEEP-7-deprecate-library
DEEP-7: Final realease
2 parents e2ff8b3 + ae952c7 commit f3c3249

12 files changed

+136
-81
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ matrix:
55
- php: 7.3
66
- php: 7.4
77
- php: 8.0
8+
- php: 8.1
89
- php: nightly
910
allow_failures:
1011
- php: nightly

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [4.0.0] - 2022-**-05
10+
### Added
11+
- marked Package as abandoned
12+
- PHP 8.1 compatibility
13+
- glossary_id to translate-method
14+
- ability to run Integration-Tests against custom host if needed (Free/Pro)
15+
### Changed
16+
- migrated phpunit.xml.dist
17+
- fixed some Tests and general Maintenance such as Typos in README.md
18+
- **Breaking Change!** standard DEEPL_HOST to free again
19+
- **Breaking Change!** default source Langauge form DE to empty so DeepL will decide
20+
### Removed
21+
922
## [3.0.1] - 2021-07-09
1023
### Added
1124
### Changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# The MIT License (MIT)
22

3-
Copyright (c) 2019 babymarkt.de GmbH <entwicklung@babymarkt.de>
3+
Copyright (c) 2018-2022 babymarkt.de GmbH <entwicklung@babymarkt.de>
44

55
> Permission is hereby granted, free of charge, to any person obtaining a copy
66
> of this software and associated documentation files (the "Software"), to deal

README.md

+34-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# deepl-php-lib
2+
***
3+
## Deprecated Library !
24

5+
Hello everyone,
6+
7+
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]).
8+
9+
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.
10+
11+
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.
12+
13+
Otherwise, we recommend you to check out the new library coming from [DeepL][link-deepl-php-lib-github].
14+
15+
Thank you to everyone who contributed to this project over the years.
16+
17+
***
318
[![Latest Version on Packagist][ico-version]][link-packagist]
419
[![Software License][ico-license]](LICENSE.md)
520
[![Build Status][ico-travis]][link-travis]
@@ -39,7 +54,7 @@ Use the DeepL API Pro:
3954
use \BabyMarkt\DeepL\DeepL;
4055

4156
$authKey = '<AUTH KEY>';
42-
$deepl = new DeepL($authKey,2,'api.deepl.com');
57+
$deepl = new DeepL($authKey,2,'api-free.deepl.com');
4358
```
4459

4560
### Translate
@@ -69,7 +84,7 @@ foreach ($translations as $translation) {
6984
| param | Description |
7085
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
7186
| $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. |
72-
| $sourceLang | Language of the text to be translated. <br>default: de |
87+
| $sourceLang | Language of the text to be translated. <br>default: "" (DeepL will auto-detect) |
7388
| $targetLang | The language into which the text should be translated. <br> default: en |
7489
| $tagHandling | Sets which kind of tags should be handled. Options currently available: "xml" |
7590
| $ignoreTags | Array of XML tags that indicate text not to be translated. <br> default: null |
@@ -123,21 +138,21 @@ Create a glossary
123138
$glossary = $deepl->createGlossary('MyGlossary', ['Hallo' => 'Hello'], 'de', 'en');
124139
```
125140

126-
| param | Description |
127-
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
128-
| $name | Glossary name
129-
| $entries | Array of entries
130-
| $sourceLanguage | The source language into which the glossary rule apply |
131-
| $targetLanguage | The target language into which the glossary rule apply |
141+
| param | Description |
142+
|-----------------|--------------------------------------------------------|
143+
| $name | Glossary name |
144+
| $entries | Array of entries |
145+
| $sourceLanguage | The source language into which the glossary rule apply |
146+
| $targetLanguage | The target language into which the glossary rule apply |
132147

133148
Delete a glossary
134149
```php
135150
$glossary = $deepl->deleteGlossary($glossaryId);
136151
```
137152

138-
| param | Description |
139-
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
140-
| $glossaryId | Glossary uuid (set by DeepL when glossary is created)
153+
| param | Description |
154+
|-------------|-------------------------------------------------------|
155+
| $glossaryId | Glossary uuid (set by DeepL when glossary is created) |
141156

142157
List glossaries
143158
```php
@@ -157,9 +172,9 @@ $glossaryInformation = $deepl->glossaryInformation($glossaryId);
157172
var_dump($glossaryInformation);
158173
```
159174

160-
| param | Description |
161-
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
162-
| $glossaryId | Glossary uuid (set by DeepL when glossary is created)
175+
| param | Description |
176+
|-------------|-------------------------------------------------------|
177+
| $glossaryId | Glossary uuid (set by DeepL when glossary is created) |
163178

164179
Get glossary entries
165180
```php
@@ -169,9 +184,9 @@ foreach ($entries as $sourceLangText => $targetLangText) {
169184
}
170185
```
171186

172-
| param | Description |
173-
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
174-
| $glossaryId | Glossary uuid (set by DeepL when glossary is created)
187+
| param | Description |
188+
|-------------|-------------------------------------------------------|
189+
| $glossaryId | Glossary uuid (set by DeepL when glossary is created) |
175190

176191
### Configuring cURL requests
177192
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
@@ -231,3 +246,5 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
231246
[link-author]: https://github.com/Baby-Markt
232247
[link-contributors]: ../../contributors
233248
[link-deepl]: https://www.deepl.com/docs-api/introduction/
249+
[link-deepl-client-libraries]:https://www.deepl.com/en/docs-api/accessing-the-api/client-libraries/
250+
[link-deepl-php-lib-github]:https://github.com/DeepLcom/deepl-php

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2+
"abandoned": "deeplcom/deepl-php",
23
"name": "babymarkt/deepl-php-lib",
34
"type": "library",
4-
"description": "DeepL API Client Library supporting PHP >= 7.3 && PHP < 8.1",
5+
"description": "DeepL API Client Library supporting PHP >= 7.3 && PHP <= 8.1",
56
"keywords": [
67
"babymarkt",
78
"deepl",
@@ -19,7 +20,7 @@
1920
}
2021
],
2122
"require": {
22-
"php": ">=7.3 <8.1",
23+
"php": ">=7.3 <8.2",
2324
"ext-json": "*",
2425
"ext-curl": "*"
2526
},

phpunit.xml.dist

+16-18
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit colors="true">
4-
<testsuites>
5-
<testsuite name="DeepL Library Test Suite">
6-
<directory>tests/</directory>
7-
</testsuite>
8-
</testsuites>
9-
10-
<filter>
11-
<whitelist>
12-
<directory suffix=".php">src/</directory>
13-
</whitelist>
14-
</filter>
15-
16-
<logging>
17-
<log type="coverage-clover" target="build/clover.xml" />
18-
</logging>
19-
</phpunit>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/clover.xml"/>
9+
</report>
10+
</coverage>
11+
<testsuites>
12+
<testsuite name="DeepL Library Test Suite">
13+
<directory>tests/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<logging/>
17+
</phpunit>

src/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ final class Client implements ClientInterface
7171
* @param integer $apiVersion
7272
* @param string $host
7373
*/
74-
public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com')
74+
public function __construct($authKey, $apiVersion = 2, $host = 'api-free.deepl.com')
7575
{
7676
$this->authKey = $authKey;
7777
$this->apiVersion = $apiVersion;
@@ -215,7 +215,7 @@ public function buildQuery($paramsArray)
215215
}
216216
}
217217

218-
$body = http_build_query($paramsArray, null, '&');
218+
$body = http_build_query($paramsArray, '', '&');
219219

220220
if (isset($textString)) {
221221
$body = $textString . '&' . $body;

src/DeepL.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
/**
88
* DeepL API client library
9-
*
10-
* @package BabyMarkt\DeepL
119
*/
1210
class DeepL
1311
{
@@ -26,7 +24,7 @@ class DeepL
2624
*/
2725
private $client;
2826

29-
public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com', ClientInterface $client = null)
27+
public function __construct($authKey, $apiVersion = 2, $host = 'api-free.deepl.com', ClientInterface $client = null)
3028
{
3129
$this->client = $client ?? new Client($authKey, $apiVersion, $host);
3230
}
@@ -64,6 +62,7 @@ public function languages($type = null)
6462
* @param array|null $nonSplittingTags
6563
* @param null $outlineDetection
6664
* @param array|null $splittingTags
65+
* @param string|null $glossaryId
6766
*
6867
* @return array
6968
*
@@ -73,7 +72,7 @@ public function languages($type = null)
7372
*/
7473
public function translate(
7574
$text,
76-
$sourceLang = 'de',
75+
$sourceLang = '',
7776
$targetLang = 'en',
7877
$tagHandling = null,
7978
array $ignoreTags = null,
@@ -82,7 +81,8 @@ public function translate(
8281
$preserveFormatting = null,
8382
array $nonSplittingTags = null,
8483
$outlineDetection = null,
85-
array $splittingTags = null
84+
array $splittingTags = null,
85+
string $glossaryId = null
8686
) {
8787
if (is_array($tagHandling)) {
8888
throw new InvalidArgumentException('$tagHandling must be of type String in V2 of DeepLLibrary');
@@ -99,6 +99,7 @@ public function translate(
9999
'split_sentences' => $splitSentences,
100100
'preserve_formatting' => $preserveFormatting,
101101
'outline_detection' => $outlineDetection,
102+
'glossary_id' => $glossaryId
102103
);
103104

104105
$paramsArray = $this->removeEmptyParams($paramsArray);

src/Glossary.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Glossary
2626
* @param string $host
2727
* @param ClientInterface|null $client
2828
*/
29-
public function __construct($authKey, $apiVersion = 2, $host = 'api.deepl.com', ClientInterface $client = null)
29+
public function __construct($authKey, $apiVersion = 2, $host = 'api-free.deepl.com', ClientInterface $client = null)
3030
{
3131
$this->client = $client ?? new Client($authKey, $apiVersion, $host);
3232
}

0 commit comments

Comments
 (0)