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

Commit 3ec0f3a

Browse files
authored
Merge pull request #16 from Baby-Markt/v2
Final Release Version 2
2 parents 1770d25 + 022fd35 commit 3ec0f3a

File tree

7 files changed

+1221
-562
lines changed

7 files changed

+1221
-562
lines changed

CHANGELOG.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
## [2.0.0] - 2020-09-??
10+
####Major overhaul of the Library with some Breaking changes. Please read before updating!
11+
### Added
12+
- Ability to change the API-Host
13+
- Support for the full Range of Request Parameters offered by DeepL
14+
- Ability to check Languages supported by DeepL-Api (source and target)
15+
- Ability to monitor API usage
16+
### Changed
17+
- **Breaking Change!** tagHandling-Parameter for translate-function was changed from array to string.
18+
- **Breaking Change!** translate now always returns an array, because in our internal usages we found, that we always converted the string to an array anyway.
19+
- Errocodes & Messages come now directly from DeepL
20+
- all Requests are now send as POST as it is recommended by DeepL
21+
- all Parameters except the API-key are send in the Requestbody
22+
- Tests are now split into Unit- and Intergration-Tests (which need an API-Key to run)
23+
### Removed
24+
- internal Error-codes
25+
- internal storage of source- and target-languages
26+
27+
## [1.1.0] - 2020-08-07
28+
### Changed
29+
- use API v2 as default [@arkadiusjonczek](https://github.com/arkadiusjonczek)
30+
31+
## [1.0.11] - 2020-06-23
32+
### Added
33+
- Add supported languages to Readme [@bestog](https://github.com/bestog)
34+
- Add Japanese and Chinese to supported languages [@bestog](https://github.com/bestog)
35+
- add formality parameter [@tomschwiha](https://github.com/tomschwiha)
36+
- Added possible Portuguese variants [@interferenc](https://github.com/interferenc)
37+
### Changed
38+
- Update README.md (added Flaggs) [@arkadiusjonczek](https://github.com/arkadiusjonczek)
39+
- Add portuguese varieties in README [@Sasti](https://github.com/Sasti)
40+
41+
## [1.0.10] - 2020-02-26
42+
### Added
43+
- create clover.xml in travis and push to scrutinizer
44+
### Changed
45+
- update scrutinizer config
46+
- change keyword in composer.json
47+
48+
all by [@arkadiusjonczek](https://github.com/arkadiusjonczek)
49+
50+
## [1.0.9] - 2020-02-03
51+
### Added
52+
- add phpcs to project and integrate it into travis-ci configuration
53+
### Changed
54+
- update composer description
55+
- fix scrutinizer ci url
56+
- disable xdebug in composer for travis-ci
57+
- update testing sequence
58+
59+
all by [@arkadiusjonczek](https://github.com/arkadiusjonczek)
60+
61+
## [1.0.8] - 2019-11-28
62+
### Changed
63+
- update tests for travis deepl api testing
64+
- fix testTranslateIgnoreTagsSuccess
65+
- update php version
66+
67+
all by [@arkadiusjonczek](https://github.com/arkadiusjonczek)
68+
69+
70+
## [1.0.7] - 2019-11-25
71+
### Added
72+
- packagist status to README.md file [@arkadiusjonczek](https://github.com/arkadiusjonczek)
73+
### Changed
74+
- Fix ignore tags [@tomschwiha](https://github.com/tomschwiha)
75+
- Update README.md [@tomschwiha](https://github.com/tomschwiha)
76+
77+
78+
## [1.0.6] - 2019-09-05
79+
### Added
80+
- add php 5.5 to travis ci test [@arkadiusjonczek](https://github.com/arkadiusjonczek)
81+
### Changed
82+
- Fix wrong error message [@shamimmoeen](https://github.com/shamimmoeen)
83+
- set dist precise for php 5.4 and php 5.5 in travis configuration [@arkadiusjonczek](https://github.com/arkadiusjonczek)
84+
85+
86+
## [1.0.5] - 2019-02-20
87+
### Added
88+
- deepl v2 api support and [@arkadiusjonczek](https://github.com/arkadiusjonczek)
89+
### Changed
90+
- fix some little errors [@arkadiusjonczek](https://github.com/arkadiusjonczek)
91+
92+
93+
## [1.0.4] - 2019-02-14
94+
### Added
95+
- Add PT and RU to supported languages [@floranpagliai](https://github.com/floranpagliai)
96+
### Changed
97+
- replace travis build php nightly build with php 7.3 [@arkadiusjonczek](https://github.com/arkadiusjonczek)
98+
### Removed
99+
100+
## [1.0.3] - 2018-19-23
101+
### Added
102+
- Add tag_handling optional param [@floranpagliai](https://github.com/floranpagliai)
103+
- Add tagHandling test [@floranpagliai](https://github.com/floranpagliai)
104+
- Add ignore_tag optional param [@floranpagliai](https://github.com/floranpagliai)
105+
- Add test for ignore tags [@floranpagliai](https://github.com/floranpagliai)
106+
- Add var typing on setIgnoreTags method [@floranpagliai](https://github.com/floranpagliai)
107+
### Changed
108+
- Fixed array syntax [@floranpagliai](https://github.com/floranpagliai)
109+
- Fixed array syntax [@floranpagliai](https://github.com/floranpagliai)
110+
- Fixed buildUrl test [@floranpagliai](https://github.com/floranpagliai)
111+
112+
113+
## [1.0.2] - 2018-06-04
114+
### Changed
115+
- send text as POST body to solve 414 uri too long error [@arkadiusjonczek](https://github.com/arkadiusjonczek)
116+
117+
## [1.0.1] - 2018-06-12
118+
### Changed
119+
- fix travis-ci build status image [@arkadiusjonczek](https://github.com/arkadiusjonczek)
120+
- update translate method return [@arkadiusjonczek](https://github.com/arkadiusjonczek)
121+
- update readme [@arkadiusjonczek](https://github.com/arkadiusjonczek)
122+
123+
124+
## [1.0.0] - 2018-06-12
125+
Initial public Release [@arkadiusjonczek](https://github.com/arkadiusjonczek)
126+
127+
128+
129+
130+
[Unreleased]: https://github.com/Baby-Markt/deepl-php-lib/compare/master...head
131+
[2.0.0]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/2.0.0
132+
[1.1.0]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.1.0
133+
[1.0.11]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.11
134+
[1.0.10]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.10
135+
[1.0.9]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.9
136+
[1.0.8]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.8
137+
[1.0.7]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.7
138+
[1.0.6]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.6
139+
[1.0.5]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.5
140+
[1.0.4]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.4
141+
[1.0.3]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.3
142+
[1.0.2]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.2
143+
[1.0.1]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.1
144+
[1.0.0]: https://github.com/Baby-Markt/deepl-php-lib/releases/tag/v1.0.0
145+
146+
What is a changelog?

README.md

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99

1010
Simple PHP Library for DeepL API. You can translate one or multiple text strings (up to 50) per request.
1111

12-
🇬🇧🇩🇪🇫🇷🇪🇸🇵🇹🇮🇹🇷🇺🇯🇵🇨🇳🇵🇱🇳🇱🇸🇪🇩🇰🇫🇮🇬🇷🇨🇿🇷🇴🇭🇺🇸🇰🇧🇬🇸🇮🇱🇹🇱🇻🇪🇪🇲🇹
12+
🇩🇪🇬🇧🇺🇸🇪🇸🇲🇽🇫🇷🇮🇹🇯🇵🇳🇱🇵🇱🇵🇹🇧🇷🇷🇺🇨🇳
13+
14+
[Official DeepL API][link-deepl]
15+
16+
[CHANGELOG](CHANGELOG.md)
1317

1418
## Install
1519

@@ -28,11 +32,12 @@ $authKey = '<AUTH KEY>';
2832
$deepl = new DeepL($authKey);
2933
```
3034

35+
### Translate
3136
Translate one Text:
3237

3338
```php
3439
$translatedText = $deepl->translate('Hallo Welt', 'de', 'en');
35-
echo $translatedText;
40+
echo $translatedText[0]['text'].PHP_EOL;
3641
```
3742

3843
Translate multiple Texts:
@@ -47,24 +52,60 @@ $text = array(
4752
$translations = $deepl->translate($text, 'de', 'en');
4853

4954
foreach ($translations as $translation) {
50-
echo $translation['text'];
55+
echo $translation['text'].PHP_EOL;
5156
}
5257
```
58+
59+
| param | Description |
60+
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
61+
| $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. |
62+
| $sourceLang | Language of the text to be translated. <br>default: de |
63+
| $targetLang | The language into which the text should be translated. <br> default: en |
64+
| $tagHandling | Sets which kind of tags should be handled. Options currently available: "xml" |
65+
| $ignoreTags | Array of XML tags that indicate text not to be translated. <br> default: null |
66+
| $formality | Sets whether the translated text should lean towards formal or informal language. This feature currently works for all target languages except "EN" (English), "EN-GB" (British English), "EN-US" (American English), "ES" (Spanish), "JA" (Japanese) and "ZH" (Chinese).<br><br>Possible options are:<br>"default" (default)<br>"more" - for a more formal language<br>"less" - for a more informal language |
67+
| $splitSentences | Array of XML tags which always cause splits <br> default: null |
68+
| $preserveFormatting | Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects. Possible values are:<br>"0" (default)<br>"1"<br>The formatting aspects affected by this setting include:<br>Punctuation at the beginning and end of the sentence<br>Upper/lower case at the beginning of the sentence |
69+
| $nonSplittingTags | Comma-separated list of XML tags which never split sentences. <br> default: null |
70+
| $outlineDetection | See: https://www.deepl.com/docs-api/handling-xml/outline-detection/ <br> default: 1 |
71+
| $splittingTags | Array of XML tags which always cause splits. <br> default: null |
72+
5373
### Supported languages
54-
* `de` - German
55-
* `en` - English
56-
* `fr` - French
57-
* `it` - Italian
58-
* `ja` - Japanese
59-
* `es` - Spanish
60-
* `nl` - Dutch
61-
* `pl` - Polish
62-
* `pt` - Portuguese
63-
* `pt-pt` - Portuguese variant
64-
* `pt-br` - Portuguese variant
65-
* `ru` - Russian
66-
* `zh` - Chinese
74+
In Version 2 we removed the internal List of supported Languages.
75+
Instead, you can now get an array with the supported Languages directly form DeepL:
76+
77+
```php
78+
$languagesArray = $deepl->languages();
79+
80+
foreach ($languagesArray as $language) {
81+
echo 'Name: '.$language['name'].' Api-Shorthand: '.$language['language'].PHP_EOL;
82+
}
83+
```
84+
You can check for the supported Source-Languages:
85+
```php
86+
$sourceLanguagesArray = $deepl->languages('source');
6787

88+
foreach ($sourceLanguagesArray as $srouceLanguage) {
89+
echo 'Name: '.$srouceLanguage['name'].' Api-shorthand: '.$srouceLanguage['language'].PHP_EOL;
90+
}
91+
```
92+
93+
Check for the supported Target-Languages:
94+
```php
95+
$targetLanguagesArray = $deepl->languages('target');
96+
97+
foreach ($targetLanguagesArray as $targetLanguage) {
98+
echo 'Name: '.$targetLanguage['name'].' Api-Shorthand: '.$targetLanguage['language'].PHP_EOL;
99+
}
100+
```
101+
### Monitoring usage
102+
You can now check ow much you translate, as well as the limit:
103+
```php
104+
$usageArray = $deepl->usage();
105+
106+
echo 'You have used '.$usageArray['character_count'].' of '.$usageArray['character_limit'].' in the current billing period.'.PHP_EOL;
107+
108+
```
68109
## Testing
69110

70111
Run PHP_CodeSniffer Tests:
@@ -93,7 +134,7 @@ composer test:all
93134

94135
## Credits
95136

96-
- [Arkadius Jonczek][link-author]
137+
- [babymarkt.de GmbH][link-author]
97138
- [All Contributors][link-contributors]
98139

99140
## License
@@ -112,5 +153,6 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
112153
[link-scrutinizer]: https://scrutinizer-ci.com/g/Baby-Markt/deepl-php-lib/code-structure
113154
[link-code-quality]: https://scrutinizer-ci.com/g/Baby-Markt/deepl-php-lib
114155
[link-downloads]: https://packagist.org/packages/babymarkt/deepl-php-lib
115-
[link-author]: https://github.com/arkadiusjonczek
156+
[link-author]: https://github.com/Baby-Markt
116157
[link-contributors]: ../../contributors
158+
[link-deepl]: https://www.deepl.com/docs-api/introduction/

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
"license": "MIT",
1515
"authors": [
1616
{
17-
"name": "Arkadius Jonczek",
18-
"email": "jonczek@babymarkt.de"
17+
"name": "Entwicklungsteam babymarkt.de",
18+
"email": "entwicklung@babymarkt.de"
1919
}
2020
],
2121
"require": {
22-
"php": ">=5.3 <8.0"
22+
"php": ">=5.3 <8.0",
23+
"ext-json": "*",
24+
"ext-curl": "*"
2325
},
2426
"require-dev": {
25-
"php": ">=5.3 <8.0",
2627
"phpmd/phpmd": "2.4.*",
2728
"phpunit/phpunit": "^4.8",
2829
"squizlabs/php_codesniffer": "^2.9"

0 commit comments

Comments
 (0)