Download the PHP package octfx/deeply without Composer

On this page you can find all versions of the php package octfx/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

DeepLy

DeepL.com is a great, new translation service. It provides better translations compared to other popular translation engines. DeepLy is a PHP package that implements a client to interact with DeepL via their API, with optional Laravel integration.

Installation

Through Composer:

From then on you may run composer update to get the latest version of this library.

It is possible to use this library without using Composer but then it is necessary to register an autoloader function.

This library requires PHP 7.2 or higher, the mbstring, and json extension.

Deepl offers a free API Key with a 500k characters translation limit per month. Vist DeepL-com to request an API key.

Usage Example

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. 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 supportsSourceLangCode($langCode) and supportsTargetLangCode($langCode).

Translation formality

The DeepL API allows to specify the formality of the translated text.
This feature currently works for all target languages except "ES" (Spanish), "JA" (Japanese) and "ZH" (Chinese).
Possible options are:

Auto-Detect Language

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 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.

Supported Languages

All supported languages by DeepL can be requested by calling

DeepL(y) supports these source languages:

Code Language
auto Auto detect
DE German
EN English
FR French
IT Italian
JA Japanese
ES Spanish
NL Dutch
PL Polish
PT Portuguese
RU Russian
ZH Chinese

DeepL(y) supports these target languages:

Code Language
DE German
EN-GB English (British)
EN-US English (American)
EN DEPRECATED
FR French
IT Italian
JA Japanese
ES Spanish
NL Dutch
PL Polish
PT DEPRECATED
PT-PT Portuguese (all)
PT-BR Portuguese (Brazilian)
RU Russian
ZH Chinese

Note that auto detection only is possible for the source language.

Text Length Limit

According to the DeepL.com website, the length of the text that has to be translated is limited to 30000 characters. Per default DeepLy will throw an exception if the length limit is exceeded. You may call $deepLy->setValidateTextLength(false) to disable this validation.

HTTP Client

Per default DeepLy uses a HTTP client based on Guzzle. If you want to use a different HTTP client, 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.

Framework Integration

DeepLy comes with support for Laravel 5.x - 7.x and since it also supports package auto-discovery it will be auto-detected in Laravel 5.5 - 7.x

In Laravel 5.0-5.4 you manually have to register the service provider Octfx\DeepLy\Integrations\Laravel\DeepLyServiceProvider in the "providers" array and the facade Octfx\DeepLy\Integrations\Laravel\DeepLyFacade as an alias in the "aliases" array in your config/app.php config file.

DeepLy uses config('services.deepl.auth_key') to retrieve the API key, so you have to set it in the services.php settings.

Request Limit

There is a request limit. The threshold of this limit is specified in the quota documentation delivered to you by DeepL.

Internals

The "core" of this library consists of these classes:

There are also some exception classes, interfaces, an alternative HTTP client implementation that uses Guzzle and classes for the Laravel integration.

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


All versions of deeply with dependencies

PHP Build Version
Package Version
Requires ext-mbstring Version *
ext-json Version *
php Version >=7.2
guzzlehttp/guzzle Version ^6.3||^7.0
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 octfx/deeply contains the following files

Loading the files please wait ....