Please use the current ProcessWire module located in this repository
Fluency is a module that brings DeepL's powerful AI deep learning translation engine to the ProcessWire CMF/CMS. With minimal configuration and effort, ProcessWire's native multi-language fields are enhanced with a button to translate the content entered under the default language to the language under the field's currently selected language.
Fluency can be added to new websites in development, existing websites adding multi-language abilities, or to websites that already have multi-language capabilities where it is desireable to have high quality translation built in.
Please note, this is an alpha release. Please use in production after thorough testing for your own project and create Github issues for bugs found if possible.
DeepL is an advanced language translation engine that provides industry-leading results when compared to other automated solutions. It handily beats the quality and accuracy of offerings from companies like Facebook, Google, and Microsoft. DeepL has been praised for it's ability to reproduce language translations that read like native speech.
In addition to its quality and power, DeepL is able to parse XML/HTML tags and translate them while retaining the markup structure. This allows for incredible opportunities in integrating DeepL with web-based applications as Fluency has done with ProcessWire.
Fluency brings many features to ProcessWire and provides an experience that feels native to the CMS and complements the powerful multi-language capabilities already built into it's core. Any field that can be a multi-language field can be translated by Fluency. These include:
Best of all, you don't have to modify the way you build out your ProcessWire site. Use any field in any configuration. Fluency scans the page for multi-language fields and adds the ability to translate. Fields like Repeater and Repeater Matrix which load or add additional items using AJAX are compatible thanks to scripts that watch for new fields and add Fluency functionality as they appear on page.
Fluency is free to use. There is no cost for this module and it can be used on any site that you build with ProcessWire.
To use Fluency you must have a Developer account with DeepL. The Developer account provides access to their REST API which is used to power Fluency. DeepL has two account types which are Free and Pro and both can be used with Fluency.
To learn more about DeepL Developer accounts and sign up, click here to find out more.
That's it! All multi-language fields should now have click to translate buttons and a translator tool is available in the Admin menu bar.
If no langauges are present in ProcessWire or if languages are present and not configured with Fluency, it is still possible to use the translator tool in the Admin menu as long as a valid API key is present and the current user is assigned a role with the fluency-translate
permission.
The Fluency module is a ProcessWire interface for bringing DeepL translation to the admin and content editing screens. There are two ways to access translation in your scsripts and templates. The translate()
method for both is identical and is as follows:
$fluency->translate(
string $sourceLanguageCode,
string|array $contentToTranslate,
array $additionalApiParameters,
array $ignoredStrings
);
This requires that your current user has the fluency-translate
permission. This will use the API key from the ProcessWire configuration screen as well as the global ignored strings, preserve formatting, etc. It does not reference configured languages as those are defined manually when translating so all are available when using the module directly.
$fluency = $modules->get('Fluency');
// Simple example, for more complex requests, including additional API parameters
// see the DeepL class call below. Any additional configurations will be merged
// with the module's configuration.
$result = $fluency->translate('EN', 'Hello!', 'ES');
echo $result->data->translations[0]->text;
This does not use any configurations in the ProcessWire configuration screen and requires that you provide your DeepL API key as well as any API parameters. This does not require any permissions to use.
// Namespaced under ProcessWire
use DeepL;
$deepl = new DeepL([
'apiKey' => 'your-deepl-api-key-here'
'accountType' => 'pro' // Options are 'pro' and 'free'
]);
// Here is an extended example
$result = $deepl->translate(
'EN',
[
'Hello my friend!',
'Goodbye, but not forever!!'
],
'ES',
[
'preserve_formatting' => 1
],
[
'friend',
'forever'
]
);
// An array was passed, so the result is iterable
foreach ($result->data->translations as $translation) {
echo $translation . '<br>';
}
Additional methods are available when calling either Fluency or DeepL directly.
getApiUsage()
- Gets the current API usage
getLanguageList()
- Gets all langauges DeepL translates from and to