All Projects → SC-Networks → deepl-api-connector

SC-Networks / deepl-api-connector

Licence: MIT license
Connector library for deepl.com rest translation api

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to deepl-api-connector

deepl-php-lib
🧠 DeepL API Client Library supporting PHP >= 7.3
Stars: ✭ 50 (+316.67%)
Mutual labels:  i18n, translations, translator, deepl, deepl-api, deepl-client
tarjama
This package allows you to translate your models fields. `2.0` version will be continued here: https://github.com/fevrok/laravel-translatable
Stars: ✭ 2 (-83.33%)
Mutual labels:  translations, translator, translation
Translation
The Translation component provides tools to internationalize your application.
Stars: ✭ 6,196 (+51533.33%)
Mutual labels:  i18n, translator, translation
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (+741.67%)
Mutual labels:  i18n, translations, translation
Mojito
An automation platform that enables continuous localization.
Stars: ✭ 256 (+2033.33%)
Mutual labels:  i18n, translations, translation
Talkr
Talkr is a super small i18n provider for React applications. It supports Typescript, has 0 dependencies, and is very easy to use.
Stars: ✭ 129 (+975%)
Mutual labels:  i18n, translations, translation
simple-translator
Simple, universal translation with pure JavaScript.
Stars: ✭ 58 (+383.33%)
Mutual labels:  i18n, translator
Flutter translate
Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
Stars: ✭ 245 (+1941.67%)
Mutual labels:  i18n, translations
django-i18nfield
Store internationalized strings in Django models with full forms support
Stars: ✭ 32 (+166.67%)
Mutual labels:  i18n, translation
translate
A module grouping multiple translation APIs
Stars: ✭ 321 (+2575%)
Mutual labels:  translator, deepl
Domino-English-Translation
🌏 Let's translate Domino, a Japanese MIDI editor!
Stars: ✭ 29 (+141.67%)
Mutual labels:  i18n, translations
pH7-Internationalization
🎌 pH7CMS Internationalization (I18N) package 🙊 Get new languages for your pH7CMS website!
Stars: ✭ 17 (+41.67%)
Mutual labels:  i18n, translations
Tempura
Pure Clojure/Script i18n translations library
Stars: ✭ 211 (+1658.33%)
Mutual labels:  i18n, translation
Weblate
Web based localization tool with tight version control integration.
Stars: ✭ 2,719 (+22558.33%)
Mutual labels:  i18n, translation
deepl-python
Official Python library for the DeepL language translation API.
Stars: ✭ 548 (+4466.67%)
Mutual labels:  translator, deepl
Glotpress Wp
🌍 🌎 🌏 GlotPress is a WordPress plugin to let you set up your own collaborative, web-based software translation tool.
Stars: ✭ 205 (+1608.33%)
Mutual labels:  i18n, translation
I18next Express Middleware
[deprecated] can be replaced with i18next-http-middleware
Stars: ✭ 195 (+1525%)
Mutual labels:  i18n, translation
deepl-rb
A simple ruby gem for the DeepL API
Stars: ✭ 38 (+216.67%)
Mutual labels:  translator, deepl
LorittaLocales
🌎 Loritta's localization files, bringing Loritta's cuteness to everyone around the world!
Stars: ✭ 21 (+75%)
Mutual labels:  i18n, translations
mobx-react-intl
A connector between mobx-react and react-intl
Stars: ✭ 32 (+166.67%)
Mutual labels:  i18n, translation

deepl-api-connector - Unofficial PHP Client for the API of deepl.com.

Monthly Downloads License Build Status

Requirements

Compatibility

Connector-Version PHP-Version(s)
master (dev) TBD
3.x (features and bugfixes) 7.4, 8.0, 8.1
2.x (bugfixes only) 7.3, 7.4, 8.0, 8.1
1.x (EOL) 7.2, 7.3, 7.4

Install

Via Composer

$ composer require scn/deepl-api-connector

Usage

Api client creation

The DeeplClientFactory supports auto-detection of installed psr17/psr18 implementations. Just call the create method and you are ready to go

require_once __DIR__  . '/vendor/autoload.php';

use \Scn\DeeplApiConnector\DeeplClientFactory;

$deepl = DeeplClientFactory::create('your-api-key');

Optionally, you can provide already created instances of HttpClient, StreamFactory and RequestFactory as params to the create method.

require_once __DIR__  . '/vendor/autoload.php';

use \Scn\DeeplApiConnector\DeeplClientFactory;

$deepl = DeeplClientFactory::create(
    'your-api-key',
    $existingHttpClientInstance,
    $existingStreamFactoryInstance,
    $existingRequestFactoryInstance,
);

If a custom HTTP client implementation is to be used, this can also be done via the DeeplClientFactory::create method. The Client must support PSR18.

Get Usage of API Key

require_once __DIR__  . '/vendor/autoload.php';

$deepl = \Scn\DeeplApiConnector\DeeplClientFactory::create('your-api-key');

try {
    $usageObject = $deepl->getUsage();
    
    
    .......
}

Get Translation

require_once __DIR__  . '/vendor/autoload.php';

$deepl = \Scn\DeeplApiConnector\DeeplClientFactory::create('your-api-key');

try {
    $translation = new \Scn\DeeplApiConnector\Model\TranslationConfig(
        'My little Test',
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_DE
        ...,
        ...,
    );

    $translationObject = $deepl->getTranslation($translation);
        
    .......
    
    OR
    
    $translationObject = $deepl->translate('some text', \Scn\DeeplApiConnector\Model\TranslationConfigInterface::LANGUAGE_DE);
}

Add File to Translation Queue

require_once __DIR__  . '/vendor/autoload.php';

$deepl = \Scn\DeeplApiConnector\DeeplClientFactory::create('your-api-key');

try {
    $fileTranslation = new \Scn\DeeplApiConnector\Model\FileTranslationConfig(
        file_get_contents('test.txt'),
        'test.txt',
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_EN,
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_DE
    );

    $fileSubmission = $deepl->translateFile($fileTranslation);

    $fileSubmission->getDocumentId() 
    
    .....
}

Check File Translation Status

require_once __DIR__  . '/vendor/autoload.php';

$deepl = \Scn\DeeplApiConnector\DeeplClientFactory::create('your-api-key');

try {
    $fileTranslation = new \Scn\DeeplApiConnector\Model\FileTranslationConfig(
        file_get_contents('test.txt'),
        'test.txt',
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_EN,
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_DE
    );

    $fileSubmission = $deepl->translateFile($fileTranslation);

    $translationStatus = $deepl->getFileTranslationStatus($fileSubmission);
    
    if ($translationStatus->getStatus() === \Scn\DeeplApiConnector\Enum\FileStatusEnum::FILE_TRANSLATION_DONE)
    {
    ....
    }
}

Get Translated File Content

require_once __DIR__  . '/vendor/autoload.php';

$deepl = \Scn\DeeplApiConnector\DeeplClientFactory::create('your-api-key');

try {
    $fileTranslation = new \Scn\DeeplApiConnector\Model\FileTranslationConfig(
        file_get_contents('test.txt'),
        'test.txt',
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_EN,
        \Scn\DeeplApiConnector\Enum\LanguageEnum::LANGUAGE_DE
    );

    $fileSubmission = $deepl->translateFile($fileTranslation);

    $file = $deepl->getFileTranslation($fileSubmission);

    echo $file->getContent();
    .....
}

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].