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

Commit 536d36d

Browse files
add example for multiple text string translations
1 parent 2dd22eb commit 536d36d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DeepL PHP Library
22

3-
Simple PHP Library for DeepL API.
3+
Simple PHP Library for DeepL API. You can translate one or multiple text strings (up to 50) per request.
44

55
## Installation
66

@@ -12,16 +12,37 @@ composer require babymarkt/deepl-php-lib
1212

1313
## Usage
1414

15+
Create an instance with your auth key:
16+
1517
```php
16-
$authKey = 'AUTH KEY';
18+
$authKey = '<AUTH KEY>';
1719
$deepl = new DeepL($authKey);
20+
```
21+
22+
Translate one Text:
1823

24+
```php
1925
$result = $deepl->translate('Hallo Welt', 'de', 'en');
26+
echo $result['translations'][0]['text];
27+
```
28+
29+
Translate multiple Texts:
30+
31+
```php
32+
$text = array(
33+
'Hallo Welt',
34+
'Wie geht es dir',
35+
'Macht doch einfach mal'
36+
);
37+
38+
$result = $deepl->translate($text, 'de', 'en');
2039

21-
print_r($result);
40+
foreach ($result['translations'] as $translation) {
41+
echo $translation['text];
42+
}
2243
```
2344

24-
## Tests
45+
## Run PHPUnit Tests
2546

2647
Clone the repository.
2748

0 commit comments

Comments
 (0)