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

Commit ad43f45

Browse files
committed
- Updated README.md
1 parent 3c75c72 commit ad43f45

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Simple PHP Library for DeepL API. You can translate one or multiple text strings
1111

1212
🇬🇧🇩🇪🇫🇷🇪🇸🇵🇹🇮🇹🇷🇺🇯🇵🇨🇳🇵🇱🇳🇱🇸🇪🇩🇰🇫🇮🇬🇷🇨🇿🇷🇴🇭🇺🇸🇰🇧🇬🇸🇮🇱🇹🇱🇻🇪🇪🇲🇹
1313

14+
[Official DeepL API][link-deepl]
15+
1416
## Install
1517

1618
Use composer if you want to use this library in your project.
@@ -28,11 +30,12 @@ $authKey = '<AUTH KEY>';
2830
$deepl = new DeepL($authKey);
2931
```
3032

33+
### Translate
3134
Translate one Text:
3235

3336
```php
3437
$translatedText = $deepl->translate('Hallo Welt', 'de', 'en');
35-
echo $translatedText;
38+
echo $translatedText[0]['text'].PHP_EOL;
3639
```
3740

3841
Translate multiple Texts:
@@ -47,9 +50,24 @@ $text = array(
4750
$translations = $deepl->translate($text, 'de', 'en');
4851

4952
foreach ($translations as $translation) {
50-
echo $translation['text'];
53+
echo $translation['text'].PHP_EOL;
5154
}
5255
```
56+
57+
| param | Description |
58+
|---------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
59+
| $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 parameter values may contain multiple sentences. Up to 50 texts can be sent for translation in one request. |
60+
| $sourceLang | Language of the text to be translated. <br>default: de |
61+
| $targetLang | The language into which the text should be translated. <br> default: en |
62+
| $tagHandling | Sets which kind of tags should be handled. Options currently available: "xml" |
63+
| $ignoreTags | Array of XML tags that indicate text not to be translated. <br> default: null |
64+
| $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 |
65+
| $splitSentences | Array of XML tags which always cause splits <br> default: null |
66+
| $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 |
67+
| $nonSplittingTags | Comma-separated list of XML tags which never split sentences. <br> default: null |
68+
| $outlineDetection | See: https://www.deepl.com/docs-api/handling-xml/outline-detection/ <br> default: 1 |
69+
| $splittingTags | Array of XML tags which always cause splits. <br> default: null |
70+
5371
### Supported languages
5472
In Version 2 we removed the internal List of supported Languages.
5573
Instead, you can now get an array with the supported Languages directly form DeepL:
@@ -58,17 +76,32 @@ Instead, you can now get an array with the supported Languages directly form Dee
5876
$languagesArray = $deepl->languages();
5977

6078
foreach ($languagesArray as $language) {
61-
echo $language['name'];
62-
echo $language['language'];
79+
echo 'Name: '.$language['name'].' Api-Shorthand: '.$language['language'].PHP_EOL;
6380
}
6481
```
82+
You can check for the supported Source-Languages:
83+
```php
84+
$sourceLanguagesArray = $deepl->languages('source');
6585

86+
foreach ($sourceLanguagesArray as $srouceLanguage) {
87+
echo 'Name: '.$srouceLanguage['name'].' Api-shorthand: '.$srouceLanguage['language'].PHP_EOL;
88+
}
89+
```
90+
91+
Check for the supported Target-Languages:
92+
```php
93+
$targetLanguagesArray = $deepl->languages('target');
94+
95+
foreach ($targetLanguagesArray as $targetLanguage) {
96+
echo 'Name: '.$targetLanguage['name'].' Api-Shorthand: '.$targetLanguage['language'].PHP_EOL;
97+
}
98+
```
6699
### Monitoring usage
67-
You can now check ow much you translate, as well as the limits set.
100+
You can now check ow much you translate, as well as the limit:
68101
```php
69102
$usageArray = $deepl->usage();
70103

71-
echo 'You have used '.$usageArray['character_count'].' of '.$usageArray['character_limit'].' in in the current billing period.';
104+
echo 'You have used '.$usageArray['character_count'].' of '.$usageArray['character_limit'].' in the current billing period.'.PHP_EOL;
72105

73106
```
74107
## Testing
@@ -120,3 +153,4 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
120153
[link-downloads]: https://packagist.org/packages/babymarkt/deepl-php-lib
121154
[link-author]: https://github.com/Baby-Markt
122155
[link-contributors]: ../../contributors
156+
[link-deepl]: https://www.deepl.com/docs-api/introduction/

src/DeepL.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function languages($type = null)
100100

101101
/**
102102
* Translate the text string or array from source to destination language
103+
* For detailed info on Parameters see README.md
103104
*
104105
* @param string|string[] $text
105106
* @param string $sourceLang

0 commit comments

Comments
 (0)