Download the PHP package chriskonnertz/deeply without Composer

On this page you can find all versions of the php package chriskonnertz/deeply. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package deeply

alt text

DeepLy 2

Build Status Version GitHub license Version

DeepL is a next-generation translation service. DeepLy is a dependency-free PHP library that implements a client to interact with the DeepL API using an API key. You can get an API key for free on their website. DeepLy automatically supports both the free and the pro API. For interactive demo scripts take a look at the demos folder.

Installation

This library requires PHP 8.0 or higher and the cURL extension. Install DeepLy trough Composer:

Examples

💡 An interactive PHP demo script is included. It is located at demos/demo_translate.php.

Sophisticated Example

Always wrap calls of the translate method in a try-catch-block, because they might throw an exception if the arguments are invalid or the API call fails. The exception will have an explanatory message and a specific error code.

Instead of using hardcoded strings as language arguments better use the language code constants of the DeepLy class. The class also offers methods such as getLangCodes($withAuto = true) and supportsLangCode($langCode).

If you need to specify advanced settings, use the setSettings() method: $deepLy->setSettings($glossaryId);

Auto-Detect Language

⚠️ ATTENTION: Using this method increases the usage statistics of your account!

DeepLy has a method that uses the DeepL API to detect the language of a text:

This will return 'EN'. The language of the text has to be one of the supported languages or the result will be incorrect. If you do not need the code of the language but its English name, you may call the $deepLy->getLangName($langCode) method.

The API, in general, can handle and completely translate texts that contain parts with different languages, if the language switch is not within a sentence. The detectLanguage() method will however only return the code of one language. It will throw an exception if it is unable to auto-detect the language. This will rarely happen, it is more likely that the API will return a "false positive": It will rather detect the wrong language than no language at all.

💡 An interactive PHP demo script is included. It is located at demos/demo_detect.

Supported Languages

DeepL(y) supports these languages:

Code Language Code Language
auto Auto detect KO Korean
ID Indonesian TR Turkish
IT Italian ZH Chinese
BG Bulgarian LT Lithuanian
CS Czech LV Latvian
DA Danish NB Norwegian
DE German NL Dutch
EL Greek PL Polish
EN English PT Portuguese
ES Spanish RO Romanian
ET Estonian RU Russian
FI Finnish SK Slovak
PT French SL Slovenian
HU Hungarian SV Swedish
JA Japanese

💡 Note that only the source language can be auto-detected.

Glossaries

To get a list with information about all your glossaries, do:

Output:

To get information about a specific glossary, do:

Output:

To get the translation entries of a specific glossary, do:

Output:

To create a new glossary with translation entries, do:

To delete an existing glossary, do:

💡 An interactive PHP demo script is included. It is located at demos/demo_glossaries.php.

Documents

Translating documents consists of three steps. The first step is to upload a document:

Output:

💡 The maximum upload limit for any document is 10 MB and 1.000.000 characters.

⚡ Every file upload is at least billed with 50.000 characters!

The second step is to wait for the DeepL.com API to finish processing (translating) the document. You can check the state:

Output:

In this case the document has been processed. This is indicated by "status" being "done" and "seconds_remaining" being null.

💡 The document life cycle is: queuedtranslatingdone (or error)

There are constants that you can use to check these values: DocumentState\STATUS_DONE etc.

The third step is to download the document:

If you do not want to store the file, do:

⚡ A document can only be downloaded once!

💡 An interactive PHP demo script is included. It is located at demos/demo_documents.php.

Usage Statistic

To get usage statistics, do:

Depending on the user account type, some usage types will be null. Learn more: https://www.deepl.com/de/docs-api/other-functions/monitoring-usage/

Framework Integration

DeepLy comes with support for Laravel 5.5+ and since it also supports package auto-discovery it will be auto-detected. However, you have to store your DeepL API key manually in the .env file, like this:

Afterwards you can access DeepLy like this: $ping = \DeepLy::ping();

HTTP Client

Per default DeepLy uses a minimalistic HTTP client based on cURL. If you want to use a different HTTP client, such as Guzzle, create a class that implements the HttpClient\HttpClientInterface and makes use of the methods of the alternative HTTP client. Then use $deepLy->setHttpClient($yourHttpClient) to inject it.

💡 Note: If you experience issues with the integrated cURL client that could be solved by setting the CURLOPT_SSL_VERIFYPEER to false, first read this: snippets.webaware.com.au/../

If it does not help try: $deepLy->getHttpClient()->setSslVerifyPeer(false)

💡 You can set up a proxy with: $deepLy->getHttpClient()->setProxy('ip:port', 'user:password')

Tests

Export your API key:

Run composer install from the DeepLy directory, then run the tests:

Differences to V1

To upgrade from v1 to v2, make sure you specify the API key when instantiating the DeepLy object. Apart from the changes mentioned above your v1 code should still work with v2 as long as you did not write your own HTTP client or extended the DeepLy class with a custom class. To learn more about the changes, please take a look at the changelog.

Disclaimer

This is not an official package. It is 100% open source and non-commercial.

DeepL is a product of DeepL GmbH. More info: deepl.com/publisher.html

Notes


All versions of deeply with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package chriskonnertz/deeply contains the following files

Loading the files please wait ....