https://github.com/tinyappsde/deepl-client
Simple PHP client for the DeepL translation API
https://github.com/tinyappsde/deepl-client
Last synced: 5 months ago
JSON representation
Simple PHP client for the DeepL translation API
- Host: GitHub
- URL: https://github.com/tinyappsde/deepl-client
- Owner: tinyappsde
- License: mit
- Created: 2021-03-27T11:24:57.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-01T00:00:37.000Z (about 4 years ago)
- Last Synced: 2025-08-14T02:52:33.485Z (10 months ago)
- Language: PHP
- Size: 37.1 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeepL Client
Simple PHP DeepL API client that supports PHP 8.
## Installation
`composer require tinyapps/deepl-client`
## Usage
```php
use TinyApps\DeepL\Translator;
use TinyApps\DeepL\Options;
use TinyApps\DeepL\TargetLanguage;
$translator = new Translator('your_api_key');
$result = $translator->translate(
text: 'Hello World',
source: null, // let's DeepL auto-detect the source language
target: TargetLanguage::GERMAN,
preserveFormatting: false,
splitSentences: Options::SPLIT_SENTENCES_DEFAULT,
formality: Options::FORMALITY_DEFAULT,
);
$result->getText(); // translated text
$result->getDetectedSourceLanguage(); // EN
```
## Unit Test
Run `DEEPL_AUTH_KEY=[your key] composer test`