Download the PHP package marketforce-info/azure-translator without Composer

On this page you can find all versions of the php package marketforce-info/azure-translator. 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 azure-translator

MarketforceInfo/AzureTranslator

Code Checks Latest Stable Version Total Downloads Licence

Sends batches of messages to be translated to the Azure translate service. Has the option of handling variables as a formatted message.


Installation

Requirements

Usage

More in depth example of using the Builder class.

Translated Message

The onTranslate callback method receives a DTO translation of an individual translated message for a language. It contains four properties:

$message is a string of the translated message.

$language is a Language enum of the language the message has been translated into.

$traceId is a trace ID used to track requests (see below for more information).

$state is user specified data specific to the original untranslated message.

The state is something that can be optionally set at the point of request (translate).

Then in the onTranslate callback.

Translate Request

Batching of the requested messages is handled automatically. The ability to pass messages to be translated is done via the Delegate class. The begin method can not be called until the onTranslate behaviour has been defined.

Features

HTTP Client

This library relies on three PSR interface implementations to be provided. ClientInterface for the HTTP client, RequestFactoryInterface to create a request and StreamFactoryInterface to create the request body. For example, in the case of the Guzzle implementation, the request and stream factory are the same implementation.

Providers

Authentication

There are two methods of specifying an authentication token.

Anything more complicated should be handled through plugins/middleware in the HTTP Client.

Message Format

By default, there is no message formatting. The following outlines alternatives to allow for different translation behaviours.

Basic

Allows for basic syntax substitution in messages. For example

The formatter will substitute the variables, so they won't be translated and then replace them in the final translated message.

Basic formatter defaults to {} style syntax but this can be changed in the constructor.

ICU Message Format

Requires an additional component which parses the ICU message format so that a representation can be sent to the translation service.

Installation

Usage
Caveat

The process of creating a representation to send to the translation service produces a verbose output which could have a detrimental effect on the character count and subsequently the billing by the Azure service. Additionally, the ICU parsing attempts to achieve the best translation outcome by composing variations of the messages when the format of a ICU message uses select, selectordinal or plural.

Custom Message Format

It's possible to create a custom message format class. The withMessageFormatter method accepts any implementation of the MessageFormatter interface.

Tracing Requests

Each individual request to the Azure service includes a Client Trace ID. By default, this is handled automatically. This can be overridden with the following method.

User defined function

Generator function

As shown, the call back is passed a parameter which allows the use of the internal generator function. This is useful in scenarios where a trace ID is recorded for every request made.

Handling Profanity

Azure has three options for handling profanity. None, deleted or marked with asterisks or tags. The component allows this to be specified. By default, no profanity handling will be enabled. It allows for a callback to customise the way profane phrases are displayed.

Methods available

Getting Metric Data

On each request to the translate service, information about the number of characters processed is returned in the process. This can be retrieved on completion.

This returns an array of each request made and the data returned.

Contributions

Contributions gratefully accepted in the form issues or PRs.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

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


All versions of azure-translator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1|^8.2
ext-json Version *
ext-mbstring Version *
psr/http-client-implementation Version *
psr/http-factory-implementation Version *
psr/http-message-implementation 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 marketforce-info/azure-translator contains the following files

Loading the files please wait ....