Project

General

Profile

Actions

Feature #94539

open

Documentation on how to work with 1:n and n:1 relations and translations

Added by Rozbeh Chiryai Sharahi about 3 years ago. Updated 30 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
2021-07-12
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

While in TYPO3 v8 it was possible to assign relations via default-language-uid, on v9 this is not possible anymore.

Given following example:

Car-table:

uid: 1, name: Some Car
uid: 2, name: Some Car (translation), l10n_parent: 1, sys_language_uid: 1, l10n_parent:1

Owner-table

uid: 1, name: Robert, car: 1
uid: 2, name: Robert (translation), car: 1, sys_language_uid: 1, l10n_parent: 1

Here we are pointing even the translation of Robert to the default language. This was working well in TYPO3 v8 when querying on Extbase for translations:

$query->eq('car.owners.name', 'Robert')

Nevertheless on v9 this query will not work anymore, instead we have to point relations to the translated ID. This is related to the LEFT-JOIN and WHERE clause that is created.

SELECT * FROM car
LEFT JOIN owner ON car.id = owner.car
WHERE car.sys_language_uid=1 -- This can not work in combination with left join of tables where translations are pointing to default language
AND owner.name='Robert'

Conclusion/Suggestion

None of the languageOverlayModes (true, false, 'hideNotTranslated') is compatible with relations that point to original languages, therefore I think this should be stated somewhere. In general there seems to be a lack of extbase translation documentation. Am I right?

Actions #1

Updated by Rozbeh Chiryai Sharahi about 3 years ago

  • Subject changed from Docs: Improve documentation on extbase-localization regarding 1:n relations to Documentation on how to work with 1:n and n:1 relations and translations

Hello,

it would be nice to add a language/localization/translation section to https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/6-Persistence/3-implement-individual-database-queries.html.

It is currently not possible to research how TYPO3 wants relations to be set. For instance with version 9 the language handling has changed and with that the queries created by EXTBASE.

This came to my mind when i tried to find out how TYPO3 wants relations of translations to be set. Shall they point to default language? Shall they point to translated records? Searching in the docs was successless.

It would be nice to have a documentation on how queries are build regarding language settings. Similar to this one:

https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/6-Persistence/3-implement-individual-database-queries.html#n-relation-has-many

Why would this be important imo:

Taking the relations of TYPO3 as an example:

On TCA we can configure freely if we want our relations to point to translations or to default languages.

1) foreign_table_where => 'AND record.sys_language_uid=0'
2) foreign_table_where => 'AND record.sys_language_uid=###CURRENT_LANGUAGE###'

Nevertheless on extbase only 2) is an option in order to do statements like:

$query->matching($query->equals('child.title','some title'));

In TYPO3 v8 1) & 2) would work, but on v9 not, since the queries is created as following

SELECT * FROM record
LEFT JOIN child ON record.uid = child.parent
WHERE child.title='some title'
AND record.sys_language_uid=1 <-- if we filter the select by sys_lang=1 this means pointing to default lang on child is no longer possible

Actions #2

Updated by Benni Mack 30 days ago

  • Private changed from Yes to No
Actions #3

Updated by Garvin Hicking 30 days ago

  • Status changed from New to Needs Feedback

Is this still something you're interested in? Maybe we can find acceptable ways of documenting this together.

Actions

Also available in: Atom PDF