This extension extends the TYPO3 translation handling by translation records that can be edited by backend users. In this way backend users are able to translate labels without having access to the language files.
This extension can also be used to translate forms created with the Form Editor.
In the frontend the labels appear underlined with a red line. A tooltip with its name appears on mouseover. A click on the label name opens the new translate module in the admin panel to edit the translation for the label inline.
Additionally you find a second tab in the new module in the admin panel that shows all labels found on the current page listing the corresponding language files and eventually existing overrides or translation records.
This view is especially interesting for developers.
The development and the public-releases of this package is generously sponsored by my employer https://www.sitegeist.de.
Install the extension and activate it in Extension Manager or via composer:
composer require sitegeist/translatelabels:^1
composer require sitegeist/translatelabels
translate_labels
into your
root TYPOSCRIPT template.Add the following TYPOSCRIPT to your template:
plugin.tx_translatelabels.settings.storagePid = 4711
Replace 4711
with the uid of the sysfolder you just created for
your translated labels.
Be aware that this setting has to be defined for all pages using this extension and also for all sysfolders containing the translation records.
Due to the not yet fixed bug https://forge.typo3.org/issues/87038 in TYPO3 9.5.9 and TYPO3 10.1 you have to apply a patch to your TYPO3 sources at present.
Use the latest patch set for your TYPO3 version attached to the issue.
Alternatively you can use a patch included in this extension for convenience.
Quick guide to apply the patch
Instructions for applying a patch to the TYPO3 sources (german)
Without this patch TYPO3 is not able to create translations of label records having the same key as their related record in the default language.
translatelabels | TYPO3 | Changes |
---|---|---|
1.0.x | 9.5.x | Initial release |
1.1.x | 9.5.x | Removed LLL:EXT: prefix from label keys |
2.0.x | 10.1.x | Compatibility for TYPO3 10.1 |
2.1.x | 11.5.x | Compatibility for TYPO3 11.5 |
2.3.0 | 11.5.x | Compatibility for PHP 8.1 |
2.3.2 | 11.5.x | Added event dispatcher to show translate labels or not |
2.3.5 | 11.5.x | Bugfix: PHP Warning: Array to string conversion |
2.3.6 | 11.5.x | Bugfix: PHP Warning: Array to string conversion |
admPanel.enable.all = 1
in User TSconfig or admPanel.enable.translatelabels = 1
1.2 Set config.admPanel = 1
in TypoScript TemplateBackend users who are allowed to create and edit translations need to have ...
Access
)Translation
(set them in BE module Backend-User
)Backend-User
)The extension overloads the f:translate fluid view helper and
renders a tag LLL:("<translation>","<key>")
for each label (only,
if you are logged in as BE user, otherwise the labels are rendered
as usual).
After all processing of frontend rendering the LLL: tags are transformed into HTML markup to display a dashed red line below each label with a tooltip showing the language file and the labels key. This also occurs only while being logged in as BE user.
This extension can be used to translate forms created with form editor including validation messages, labels, placeholders, descriptions etc. Therefore this extension overrides the following two view helpers of form framework:
Form framework uses special chaining of translations for elements. For further information have a look at: https://docs.typo3.org/c/typo3/cms-form/9.5/en-us/Concepts/FrontendRendering/Index.html#translation
This extension implements a simplified approach to override these translations:
You can only override the most specific translation of an element using
the path <formDefinitionIdentifier>.element.<elementIdentifier>.properties.<propertyName>
.
Examples:
registerForm.element.first-name.properties.label
registerForm.element.first-name.properties.description
value1
of a radio button
registerForm.element.radiobutton-1.properties.options.value1
Second
register.element.multicheckbox-1.properties.options.Second
registerForm.element.text-1.properties.fluidAdditionalAttributes.placeholder
If a translation is defined for an element in the database then this will always take precedence over others defined in language files regardless of priority in the chain defined by form framework.
This behaviour is subject of change in the future.
If custom error messages are defined in form editor then only these messages are used for all languages and no translation chain takes place. This is default behaviour in form framework.
With this extension you can override these static values.
Example:
registerForm.validation.error.text-2.1428504122
The extension is completely compatible with TYPO3 caching mechanisms.
Caching is disabled if translation labels are activated in admin panel. This is because otherwise the markup showing the translation labels would be cached and delivered as content also for frontend users not being also logged in as backend users.
Due to API restrictions it is not possible to extend the old language
handling of plugins based on AbstractPlugin (a.k.a. pi_base plugins).
Instead each inherited class has to be extended directly via xclass.
This extension has an example for this for the plugin fe_login in
Classes/Plugin/FrontendLoginController.php
.
You can overload other pi_base plugins using the following code in your ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Felogin\\Controller\\FrontendLoginController'] = array(
'className' => 'Sitegeist\\Translatelabels\\Plugin\\FrontendLoginController'
);
ext_localconf.php
// Examples for overriding language files
$overrideLanguageFiles = [
'default' => [
'EXT:felogin/Resources/Private/Language/locallang.xlf' => 'felogin/felogin.xlf'
],
'de' => [
'EXT:felogin/Resources/Private/Language/locallang.xlf' => 'felogin/de.felogin.xlf'
]
];
foreach ($overrideLanguageFiles as $language => $languageFiles) {
foreach ($languageFiles as $originalLanguageFile => $overrideLanguageFile) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'][$language][$originalLanguageFile][] =
'EXT:my_extension/Resources/Private/Language/Overrides/' . $overrideLanguageFile;
}
}
Note that my_extension
should be replaced with your extension key.
$ cd typo3conf/ext/translatelabels
$ composer install
$ vendor/bin/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml Tests/Unit/Renderer/FrontendRendererTest.php