Download the PHP package tobento/app-machine-translator without Composer

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

App Machine Translator

Application-level integration for machine translation, built on top of the Machine Translator Service.

Table of Contents

Getting Started

Add the latest version of the app machine-translator project running this command.

Requirements

Documentation

App

Check out the App Skeleton if you are using the skeleton.

You may also check out the App to learn more about the app in general.

Machine Translator Boot

The MachineTranslator boot integrates the Tobento Machine Translator Service into your application.

It provides:

Machine Translator Config

The configuration for the machine translator is located in the app/config/machine-translator.php file at the default App Skeleton config location.

Here you can define the Machine Translators available to your application, as well as enable optional Translation Features.

Basic Usage

If you're new to working with machine translators in Tobento, start with the
Basic Usage section of the Machine Translator Service.
It explains how to create and use translators, how translation results are structured, and provides the foundation for how App-Machine-Translator builds on top of the underlying service.

Features

Translate Feature

The Translate feature provides an HTTP endpoint for performing machine translations directly from your application.
It is designed for any workflow that requires on-demand machine translation through a simple HTTP API, such as backend services, admin tools, automation scripts, or JavaScript integrations.

This feature offers:

The feature installs an extended migration to support translation logging and tracking.

Config

Enable the feature in your machine-translator.php config:

[!WARNING]
Security Warning:
Disabling ACL (withAcl: false) removes all permission checks for the translation endpoint.
This should only be used during development or in trusted internal environments.

ACL Permissions

This feature defines the following ACL permission:

If you are using the App Backend, you can assign these permissions to roles or users in the backend interface.

Request Format

You may send either:

or

Additional fields:

Example Request (single)

Example Success Response

Example Request (many)

Example Success Response

For programmatic usage from JavaScript (e.g., admin tools, automation, UI helpers), see the JavaScript Translator.

Logging

The App Logging Boot is enabled by default, so no additional setup is required to log machine translation activity.

In the file you may define the logger to be used, otherwise the default logger will be used:

JavaScript Translator

The JavaScript Translator provides a lightweight client for performing machine translations from JavaScript.
It is intended for use in admin interfaces, tooling, automation, or any environment where translations need to be requested from the browser or another JS runtime.

This module communicates with the Translate Feature endpoint and offers a simple API for translating one or many texts.

Example

The following example demonstrates how to use the JavaScript Translator together with App View.
Make sure App View is installed and its boot is enabled before using this example.

This setup allows you to attach translation behavior to any element using data-machine-translator attributes.
When clicked, the element triggers a request to the Translate Feature endpoint and writes the translated text into the target field.

Example View

How It Works

The JavaScript Translator activates on any element containing a data-machine-translator attribute.
When the element is clicked, the following steps occur:

  1. Resolve the source text
    The translator determines which field(s) to read from using:

    • from (explicit source fields), or
    • from_first (fallback selector inside the nearest [data-field] container)
  2. Determine the target field
    The to attribute specifies where the translated text should be written.
    If no locale is provided, the locale is inferred from the last segment of the target name
    (e.g., text.de to de).

  3. Select the translator (optional)
    If a translator value is provided (e.g., "deepl"), it is included in the request.
    If omitted, the system automatically uses the first available translator.

  4. Send a request to the Translate Feature endpoint
    A POST request is sent to the configured url (usually the /machine-translate route).

  5. Write the translated text into the target field
    The response from the server is inserted into the field defined by to.

  6. Display user feedback via js-notifier
    The translator uses js-notifier to show:
    • success messages
    • validation warnings (e.g., empty source field)
    • server errors (e.g., translation failed)

This provides a smooth, interactive translation workflow without requiring custom JavaScript.

JS-Editor Support

The JavaScript Translator also supports js-editor fields. If the target field is managed by js-editor, the translated text is automatically written into the editor's content area using its data-editor-id attribute.

This allows translation buttons to work seamlessly with rich-text editors in the same way they do with standard <input> and <textarea> fields.

Integration with App CRUD

When using App CRUD, the JavaScript Translator integrates through the CRUD field system.
Fields that support machine translation automatically render the appropriate data-machine-translator attributes, and the JavaScript Translator activates on these attributes without requiring any manual JavaScript setup.

This means:

The behavior is fully driven by the field configuration in App CRUD, while the JavaScript Translator handles the client-side interaction.

For details on configuring translation in CRUD fields, see the Machine Translator Field documentation in App CRUD.

Learn More

Events For Translators

The Event Machine Translator Adapter.

To enable event dispatching, install
App Event and boot it:

Once booted, the translator will trigger the events described in the Machine Translator Adapter Events.

For listening to events, see the Add Listeners section.

Credits


All versions of app-machine-translator with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
tobento/app Version ^2.0
tobento/app-http Version ^2.0
tobento/app-migration Version ^2.0
tobento/app-language Version ^2.0
tobento/app-logging Version ^2.0
tobento/app-queue Version ^2.0
tobento/app-translation Version ^2.0
tobento/app-user Version ^2.0
tobento/service-machine-translator Version ^2.0
tobento/service-tag Version ^2.0
tobento/js-notifier Version ^1.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 tobento/app-machine-translator contains the following files

Loading the files please wait ...