This extension provides automatic translation for pages, content and TCA record
fields using DeepL supported languages.
Contribution
Contributions are essential to the success of open source projects, but they are by no means
limited to contributing code. Much more can be done, for example by
improving the documentation.
Contribution workflow
Please always create an issue on Github
before starting a change. This is very helpful to understand what kind of problem the
pull request solves, and whether your change will be accepted.
Bug fixes: Please describe the nature of the bug you wish to report and provide
how to reproduce the problem. We will only accept bug fixes if we can
can reproduce the problem.
Features: Not every feature is relevant to the majority of users.
In addition: We do not want to complicate the usability of this extension for a marginal feature.
It helps to have a discussion about a new feature before
before opening a pull request.
Please always create a pull request based on the updated release branch. This
ensures that the necessary quality checks and tests are performed as a quality
can be performed.
Sponsors
We very much appreciate the sponsorship of the development and features of the
DeepL Translate Extension for TYPO3.
DeepL "Add automatic translation flag and hint" sponsored by
The extension has to be installed like any other TYPO3 CMS extension.
You can download the extension using one of the following methods:
Use composer:
Run
composer require web-vision/deepltranslate-core
Copied!
in your TYPO3 installation.
Get it from the Extension Manager:
Switch to the module Admin Tools > Extensions.
Switch to Get Extensions and search for the extension key
deepltranslate_core and import the extension from the repository.
Get it from typo3.org:
You can always get current version from TER by downloading the zip
version. Upload the file afterwards in the Extension Manager.
The extension then needs to be configured
in order to display translation buttons in the desired languages.
Compatibility
DeepL Translate supports:
DeepL Translate version
TYPO3 Version
PHP version
Supported
5.0-5.x
12
8.1, 8.2, 8.3, 8.4
yes
4.0-4.x
11-12
7.4, 8.0, 8.1, 8.2, 8.3, 8.4
yes
3.0
9-11
>=7.4
no
2.3
9-11
>=7.4
no
Configuration
Set up API
Attention
Before using the DeepL API, you need to get an API key from your DeepL Profile.
Open the settings for deepltranslate_core and add your API key.
The correct DeepL API endpoint for free or pro plans is auto-detected
by the extension and the given API key format.
Set up translation language
Go to Site Management > Sites and edit your site configuration
Switch to tab Languages and open your target
Go to DeepL Settings and set up your Target Language (ISO Code)
Note
Although the drop-down list can also be set in the default language, there is
no point in defining a target language for the source language.
Choice a Formality
The formality configuration has been moved from the extension configuration to the SiteConfig languages.
The Formality Select field is only displayed if the selected Target-Translate of DeepL is supported.
Note
For TYPO3 projects with more than one page root and language there is an upgrade wizard,
which migrates the global formality configuration in the language config.
The same option is available in the Select field as DeepL API Supported.
deeplFormality
deeplFormality
type
string
Sets whether the translated text should lean towards formal or informal language.
Possible options:
default
The default setting. If formal or informal depends on the language
less
Less formal language. Will fail, if no formality support for language
more
More formal language. Will fail, if no formality support for language
prefer_less
Use less formal language, if possible, otherwise fallback to default
prefer_more
Use more formal language, if possible, otherwise fallback to default
Configure tables
If not set by default, you need to define the l10n_mode for the fields you
want to have translatable by deepltranslate_core.
The following chain tries to detect the language to translate into:
Set up DeepL Translation language in SiteConfiguration
* Target languages detected from DeepL will only appear
Check hreflang against DeepL supported languages
* Needed for detecting EN-GB, EN-US, PT-PT or PT-BR
Fallback to Language ISO code
For currently allowed languages see the DeepL conform language key. As this
extension retrieves available languages from the API, translations are restricted
to the languages listed in the official DeepL API documentation.
If none of these match against DeepL API, translation for this language
is disabled for usage within DeepL. Translation buttons and dropdowns
respect this setting.
Access Configuration
Access to the automatic translation functions with Deepl-Translate in the TYPO3 backend
can be defined via the following options in the user group settings.
Note
In order to be able to use the backend group authorisations, an update to the latest version
of the deepltranslate_core (web-vision/deepltranslate-core).
Allowed Translate
Allowed Translate
This setting controls the visibility of the general translation function in the
translation modal of the page module, in the translation options of data records in the list module
and in the translation selection in the page header of the page and list module.
Allowed Glossary Sync
Allowed Glossary Sync
This setting allows backend users of a backend user group with corresponding authorisation to
synchronise glossary entries of a glossary SysFolder (SysFolder with activated glossary module) towards Deepl.
Auto-translate-prefix
To enable the tagging of automatically translated pages and content, the page
activation of translated pages has been extended to provide a means of control.
This information is passed to the Page Context Fluid template, where it can be used to create a page-specific look.
To make this easier, you can also use the extension partial.
Starting with 5.x the composer package name and extension key has been renamed!
You need to migrate the extension settings from
['TYPO3_CONF_VARS']['EXTENSIONS']['wv_deepltranslate'] to
['TYPO3_CONF_VARS']['EXTENSIONS']['deepltranslate_core'].
Then you will need to replace the previous package by uninstalling it first.
Uninstall "wv_deepltranslate" using the Extension Manager.
Switch to the module Admin Tools > Extensions and filter for
wv_deepltranslate and remove (uninstall) the extension.
Ensure to remove the folder completely.
Run
rm -rf typo3conf/ext/wv_deepltranslate
Copied!
Get it from the Extension Manager:
Switch to the module Admin Tools > Extensions.
Switch to Get Extensions and search for the extension key
deepltranslate_core and import the extension from the repository.
Get it from typo3.org:
You can always get current version from TER by downloading the zip
version. Upload the file afterwards in the Extension Manager.
Version 3.x > 4.x
If you are upgrading from 3.x on TYPO3 11 LTS to 12 LTS and you have used the site
config setup for translations, you can simply update.
Upgrade with Core Upgrade
If you are upgrading from a TYPO3 version below v11, you need to define the target
languages in the site configuration. See site-setup-section
in this documentation.
Version 2.x > 3.x
Note
This Upgrade is only needed, if you are using glossary functionality.
Run the Upgrade wizard shipped with version 3. The wizard only appears, if necessary:
This wizard moves your glossaries to the new structure, fixes backend group
rights and changes the module name.
After this, you have to run a GlossarySync update, either by CLI or by backend
sync-cli
glossaries
Editors manual
How editors work with deepltranslate_core is described in the following chapters.
Once the extension is installed and the API key provided, we are ready to start
translating content elements. When translating a content element, there are four
additional options besides the normal translate and copy.
DeepL Translate (auto detect).
DeepL Translate.
DeepL translate options
Translating a page
deepltranslate_core adds a separate dropdown for DeepL translation of a page to
the list and web module. The dropdown is filtered to not translated pages and
against DeepL API possible translation languages.
Translating a single element
In list view, you are able to translate single elements by clicking the DeepL
translate button for the language you want.
Languages that are not available will have no DeepL button. In this case,
use normal translation.
Note
Fields of custom extensions need to be properly
configured to enable translation.
Auto-translate-prefix
To enable tagging of automatically translated pages and content, the page turned
on of translated pages has been extended to implement a control.
Each time content is translated, the fields are updated.
The field information "Last translation date" and "DeepL Translated content has not been checked"
are always transferred to the page object and can be queried in Fluid.
In this way, information and notes can be controlled in the Fluid template if required.
This must be added to the template by a TYPO3 administrator or developer.
When an editor is previewing a hidden page translated by DeepL, a DeepL badge is
displayed in addition to the "Preview" badge in the upper right corner.
FAQ
My dropdown in the site configuration is empty
This happens if TYPO3 cached the request from the DeepL API for allowed languages,
but no API key was provided. In this case, empty your system cache in TYPO3.
Normally no cache files should be created when no API key is provided.
If this step does not work, delete the cached files manually. The location is as follows:
composer based installation
var/cache/data/wvdeepltranslate
legacy installation
typo3temp/var/cache/data/wvdeepltranslate
After deleting the files in this directory and going to Site Configuration, the
extension will reload the cache and the dropdown should have all the translatable
language keys.
What will be the cost for DeepL API subscription?
You can find all the details regarding the usage of the DeepL API here:
Some general settings must be configured in the Extension Configuration.
Go to Admin Tools > Settings > Extension Configuration
Choose deepltranslate_core
DeepL API Key
apiKey
apiKey
type
string
Add your DeepL API Key here.
Table Configuration
deepltranslate_core supports the translation of specific fields of TCA records.
It only understands fields to be translated only if their l10n_mode
is set to prefixLangTitle.
Attention
deepltranslate_core only translates fields defined as TCA type input or text.
Other fields cannot currently be translated automatically due to limitations in
the DataHandler.
deepltranslate_core uses a DataHandler hook to detect translatable fields.
The following setup is required to make deepltranslate_core work on your table:
When API key is not set, deepltranslate_core disables all functions.
Go to Settings and fix it. Clear cache
after this.
TYPO3 Core patch required (l10n_source)
Localizing a record whose table declares a translation source field
(l10n_source) - for example content elements built with MASK - can create
a duplicate translation in the same language. This is the root cause of the
duplicated translations reported for web-vision/deepltranslate-auto-renew in
#42.
The defect is in the TYPO3 Core, not in this extension:
BackendUtility::getRecordLocalization() matches existing translations by
l10n_source when the table defines one and does not fall back to
l10n_parent. A valid translation created without populating l10n_source
(the usual result of a plain DataHandler datamap, an importer, a migration or
MASK) is not found, so DataHandler::localize() creates a second one.
The fix is upstream: forge #110281,
Gerrit 94915 (13.4).
TYPO3 v12.4 has reached ELTS and never receives the fix upstream. Until the fix
is released for v13.4, and permanently for v12.4, instances have to apply it
through a Composer patch.
This extension ships the patch file below Documentation/CorePatches/ and
declares it in its own composer.json. When the project uses
vaimo/composer-patches, nothing
has to be configured: patch declarations are collected from installed
dependencies as well, not only from the root composer.json, so having this
extension installed is enough and the patch matching the TYPO3 version in use is
applied automatically:
- Applying patches for typo3/cms-backend (1)
~ web-vision/deepltranslate-core: Documentation/CorePatches/typo3-cms-backend-110281-v12-v13.patch [NEW]
Copied!
Do not declare the same patch a second time in the project. Declarations for
the same target package are de-duplicated, the declaration of the dependency wins
and the own one is dropped silently.
Plugins which only evaluate the root composer.json - for example
cweagans/composer-patches in
its default configuration - do not pick that declaration up. Copy the patch file
into the project and declare it, scoped so it only applies to the affected
versions:
Patches the project applies to typo3/cms-backend itself may need adoption:
they have to apply on top of the changes shown below, otherwise patching fails
and aborts the Composer run. The same is true for patches provided by other
extensions for the same file.
See the general TYPO3 documentation on applying Composer patches for
project-specific setup details. The patch used by this extension:
typo3-cms-backend-110281-v12-v13.patch
diff --git a/Classes/Utility/BackendUtility.php b/Classes/Utility/BackendUtility.php
index 893f781..f442596 100644
--- a/Classes/Utility/BackendUtility.php+++ b/Classes/Utility/BackendUtility.php@@ -27,6 +27,7 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Platform\PlatformInformation;
+use TYPO3\CMS\Core\Database\Query\Expression\CompositeExpression;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
@@ -293,10 +294,7 @@
$queryBuilder->select('*')
->from($table)
->where(
- $queryBuilder->expr()->eq(- $tcaCtrl['translationSource'] ?? $tcaCtrl['transOrigPointerField'],- $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT)- ),+ self::createTranslationParentConstraint($queryBuilder, $tcaCtrl, (int)$uid),
$queryBuilder->expr()->eq(
$tcaCtrl['languageField'],
$queryBuilder->createNamedParameter((int)$language, Connection::PARAM_INT)
@@ -314,6 +312,44 @@
return $recordLocalization;
}
+ /**+ * Constraint matching all translations of the given record.+ *+ * `translationSource` (l10n_source) is preferred, since it is the more precise information for+ * translation chains. It is however not maintained by all writes - a DataHandler datamap which+ * creates a translation by only setting the language field and the transOrigPointerField leaves+ * it empty - so such records are matched by their transOrigPointerField (l10n_parent) instead.+ * Without that, valid translations would be invisible for callers like+ * `DataHandler::localize()`, which uses this lookup to prevent duplicate translations.+ *+ * @param array $tcaCtrl The `ctrl` section of the table+ */+ protected static function createTranslationParentConstraint(+ QueryBuilder $queryBuilder,+ array $tcaCtrl,+ int $uid+ ): CompositeExpression|string {+ $uidParameter = $queryBuilder->createNamedParameter($uid, Connection::PARAM_INT);+ $translationOriginPointerConstraint = $queryBuilder->expr()->eq(+ $tcaCtrl['transOrigPointerField'],+ $uidParameter+ );+ if (!isset($tcaCtrl['translationSource'])) {+ return $translationOriginPointerConstraint;+ }++ return $queryBuilder->expr()->or(+ $queryBuilder->expr()->eq($tcaCtrl['translationSource'], $uidParameter),+ $queryBuilder->expr()->and(+ $queryBuilder->expr()->eq(+ $tcaCtrl['translationSource'],+ $queryBuilder->createNamedParameter(0, Connection::PARAM_INT)+ ),+ $translationOriginPointerConstraint+ )+ );+ }+
/*******************************************
*
* Page tree, TCA related
Copied!
Reference to the headline
Copy and freely share the link
This link target has no permanent anchor assigned.The link below can be used, but is prone to change if the page gets moved.