John Davidson

php - TYPO3 Extbase Localization, follow relations from parent?


I've been researching and testing TYPO3's localization system for extensions and I'm very confused. My main problem with it is described below, in the section named TYPO3 v9 and higher in the Localizing and internationalizing an extension

Setting Typo3QuerySettings->languageOverlayMode to true makes Extbase fetch records from default language and overlay them with translated values [...] For relations, Extbase reads relations from a translated record (so it’s not possible to inherit a field value from translation source) and then passes the related records through $pageRepository->getRecordOverlay().

Why does it work like this instead of just following the relations of the default record (sys_lang_uid = 0)? Since it works this way, e.g. if you want to translate your website to 4 languages you have to maintain the same database relationships 4 times (including MM records). For example, for my Blog, if someone using it in German changes one Article and links it to another one, this change is only done for the German website, not the English one.

What I'm describing would be akin to how connected mode for Localized content works, you only want the translated records for the translated fields, everything elese (including relations) are taken from the default one. Is there any way of making it follow the relations of the default record for all languages?

Thanks a lot in advance

Here is the languages part of my site config:

title: English
enabled: true
languageId: 0
base: /
typo3Language: default
locale: en_US.UTF-8
iso-639-1: en
navigationTitle: English
hreflang: en-US
direction: ltr
flag: en-us-gb
solr_core_read: core_en
title: German
enabled: true
languageId: 1
base: /de/
typo3Language: default
locale: de_DE.UTF-8
iso-639-1: de
navigationTitle: German
hreflang: de-DE
direction: ltr
flag: de
solr_core_read: core_de
websiteTitle: ''
fallbackType: strict
fallbacks: ''
title: Spanish
enabled: true
base: /es/
typo3Language: es
locale: es_ES.UTF-8
iso-639-1: es
websiteTitle: ''
navigationTitle: Spanish
hreflang: es-ES
direction: ltr
fallbackType: strict
fallbacks: ''
flag: es
solr_core_read: ''
languageId: 3

My Answer:
> "If you want to localize records of a related model, you have to set the Typo3QuerySettings of the parent model to include the related model. Otherwise, the localization of the related model will not work."

This means that if you have a parent model with a relation to another model, you need to make sure that the Typo3QuerySettings of the parent model include the related model in order for the localization of the related model to work properly.

Here is an example of how you can set the Typo3QuerySettings in your parent model to include the related model:

* Your parent model class
class ParentModel extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {

* Initialize Object
public function initializeObject() {
$querySettings = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false); // Set this to false if needed
$querySettings->setRespectSysLanguage(true); // Set this to true to respect the language
$querySettings->setLanguageUid(0); // Set the language UID if needed

// Include the related model in the query settings


By setting the Typo3QuerySettings in this way, you ensure that the localization of the related model will work properly when accessing it from the parent model.

Rate this post

3 of 5 based on 4716 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us