Download the PHP package tobiaswolf/machine-translation without Composer

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

Machine Translation

This Kirby plugin allows you to automatically translate pages using the DeepL API. All field types are supported.

If you are using machine translation, you should inform your users of this fact.\ For example, you could display a message like this (Text available via t('tobiaswolf.machine-translation.info'))

Installation

Download

Download and copy this repository to /site/plugins/machine-translation.

Git submodule

Composer

Requirements

Setup

To use this plugin you have to set your personal Authentication Key for DeepL API. API Access / Authentication – DeepL Documentation

DeepL Options

You can set several options, provided by DeepL. Read more about the options in the API Documentation of DeepL. Each option has to be prefixed. tobiaswolf.machine-translation.deepl.{Name}

Name Type Default Description
authKey (required) string null You can find your Auth key on your account page. DeepL Documentation
split_sentences string nonewlines Possible values are: 0 no splitting at all, whole input is treated as one sentence. 1 splits on punctuation and on newlines. nonewlines splits on punctuation only, ignoring newlines
preserve_formatting bool false Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects.
formality string default You can use one of these options: default (default), more for a more formal language, less for a more informal language, prefer_more for a more formal language if available, otherwise fallback to default formality, prefer_less for a more informal language if available, otherwise fallback to default formality.
glossary_id string null Specify the glossary to use for the translation. The language pair of the glossary has to match the language pair of the request.
tag_handling string html Sets which kind of tags should be handled. Options currently available: xml, html
outline_detection bool true   API Documentation
non_splitting_tags array null List of XML or HTML tags.
splitting_tags array null List of XML or HTML tags.
ignore_tags array null List of XML or HTML tags.

Usage

Blueprint section

Add the section machine-translate to your blueprint to get the interface to translate the page.

Screenshot of Kirby Panel with Button “Translate page”

After the page is translated an object field machineTranslated with date and showInfo is saved to the translated page content. This can be used to detect machine translated pages and display a notice/warning on the frontend that the text is machine translated. You can add this object field to any fields section (optional).

API endpoint

This plugin provides an API endpoint /api/machine-translate/pages/(:any) that can be used to translate an entire page. Read Kirby’s API Guide to learn more about using the API.

The endpoint allows get and post requests. The endpoint requires a language (target language) query. When making a post request, sourceLang and forceOverwrite can be added. By default sourceLang is the default language. If forceOverwrite is false or not specified, only fields where the target field does not exist or is empty will be translated.

API endpoint to translate the site content. /api/machine-translate/site

Field method

The field method $field->translate($targetLang, $blueprintField) translates the field value and returns the field with the translated value. All field types are supported. The type of field is specified via $blueprintField['type'].

If you want to save the translated field, you can do this like this.

Page method

The page method $page->machineTranslate($targetLang, $sourceLang, $force) allows you to translate the content of a page into a target language. By default already translated fields will not be overwritten. By setting $force to true all fields will be translated, existing fields will be overwritten.

An object field machineTranslated with date and showInfo is added to the translated page content. This can be used to detect machine translated pages and display a notice/warning on the frontend that the text is machine translated.

To translate the site content, use $site->machineTranslate($targetLang, $sourceLang, $force).

Translate Class

If you want to, you can use the static method of the Translate class. Use the translate($text, $targetLang, $sourceLang) method to translate text. Make sure you pass an array as the first parameter (you can translate multiple texts at once). You can omit the third parameter to have the source language automatically detected.

Cache

Each request to DeepL is cached. This has the advantage that if the same text appears more than once on the website, a new request is not always made. This saves you Character usage of your DeepL plan.

You can disable the cache via config.

License

MIT

Credits


All versions of machine-translation with dependencies

PHP Build Version
Package Version
Requires getkirby/composer-installer Version ^1.1
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 tobiaswolf/machine-translation contains the following files

Loading the files please wait ....