Discussion:
[TYPO3-english] Extbase - working with translation
Jan Bednarik
2017-12-05 20:31:58 UTC
Permalink
Hi,

I need to work with a translation of a record, but ExtBase loads record
with UID of the translation, I always get the default language. Is there
a setting or something to surpress this behavior?

What I'm trying to do is to translate records in FE, but when I get
translation, update it and save it, the original is updated and not the
translation.

Jan
Stephan Schuler
2017-12-05 22:23:17 UTC
Permalink
Hey there.

That's not the way translations are meant to work in Extbase. You won't get very far unless you drop large parts of Extbase and work around that yourself.

You should not think in terms of records in Extbase but in terms of a rich domain model. In that mind set (at least the way Extbase provides it for you), there's no such thing as different translation records. There is only one entity that has different flavours depending on the environment. You are not meant to handle different recored UIDs for the original one or for the translation. The entity as one identifier, no matter which language you're looking at.

Of course your problem doesn't go away just because me telling you some very meta stuff. And I'm not trying to talk you out of this. But regular Extbase mechanisms just don't provide you with that kind of access.

Think about it like this: You can't query the repository "findByLanguage" twice with different language arguments and expect the same domain object to be returned as two different objects.
If they are returned as two different objects, then the language is part of your domain and not automatically handled by Extbase.
If the language is automtically handled by Extbase then the language is not part of your domain, thus both objects are equal. Ideally, they even are references to the very same thing, so `===` at PHP level returns true.

And that's the clue how to handle this: Don't use Extbase translation mechanisms (or TYPO3 translation mechanisms in general) but make the language part of your domain model. That, imho, is the only way to stay in the Extbase world for all the features we love on one hand but be able to handle translations yourelf on the other.

Regards,



Stephan Schuler
Softwareentwickler | netlogix Web Solutions

Telefon: +49 (911) 539909 - 0
E-Mail: ***@netlogix.de
Web: websolutions.netlogix.de



----------------------------
Neu: Wir sind Amazon Web Services Partner. Mehr erfahren:
https://websolutions.netlogix.de/technologie/amazon-web-services-aws
----------------------------




netlogix GmbH & Co. KG
IT-Services | IT-Training | Web Solutions
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: ***@netlogix.de | Web: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Matthias Schmidt



________________________________________
Von: typo3-english-***@lists.typo3.org <typo3-english-***@lists.typo3.org> im Auftrag von Jan Bednarik <***@bednarik.org>
Gesendet: Dienstag, 5. Dezember 2017 21:31
An: typo3-***@lists.typo3.org
Betreff: [TYPO3-english] Extbase - working with translation

Hi,

I need to work with a translation of a record, but ExtBase loads record
with UID of the translation, I always get the default language. Is there
a setting or something to surpress this behavior?

What I'm trying to do is to translate records in FE, but when I get
translation, update it and save it, the original is updated and not the
translation.

Jan
_______________________________________________
TYPO3-english mailing list
TYPO3-***@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
Jan Bednarik
2017-12-06 16:06:53 UTC
Permalink
Hi,

thanks for deep explanation. It's actually how I believed it'd be, so I
started with my own way, adding new property to hold parent so ExtBase
wouldn't know about it.

Thanks for confirming that this is the only way how to do that.

Jan
Post by Stephan Schuler
Hey there.
That's not the way translations are meant to work in Extbase. You won't get very far unless you drop large parts of Extbase and work around that yourself.
You should not think in terms of records in Extbase but in terms of a rich domain model. In that mind set (at least the way Extbase provides it for you), there's no such thing as different translation records. There is only one entity that has different flavours depending on the environment. You are not meant to handle different recored UIDs for the original one or for the translation. The entity as one identifier, no matter which language you're looking at.
Of course your problem doesn't go away just because me telling you some very meta stuff. And I'm not trying to talk you out of this. But regular Extbase mechanisms just don't provide you with that kind of access.
Think about it like this: You can't query the repository "findByLanguage" twice with different language arguments and expect the same domain object to be returned as two different objects.
If they are returned as two different objects, then the language is part of your domain and not automatically handled by Extbase.
If the language is automtically handled by Extbase then the language is not part of your domain, thus both objects are equal. Ideally, they even are references to the very same thing, so `===` at PHP level returns true.
And that's the clue how to handle this: Don't use Extbase translation mechanisms (or TYPO3 translation mechanisms in general) but make the language part of your domain model. That, imho, is the only way to stay in the Extbase world for all the features we love on one hand but be able to handle translations yourelf on the other.
Regards,
Stephan Schuler
Softwareentwickler | netlogix Web Solutions
Telefon: +49 (911) 539909 - 0
Web: websolutions.netlogix.de
----------------------------
https://websolutions.netlogix.de/technologie/amazon-web-services-aws
----------------------------
netlogix GmbH & Co. KG
IT-Services | IT-Training | Web Solutions
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Matthias Schmidt
________________________________________
Gesendet: Dienstag, 5. Dezember 2017 21:31
Betreff: [TYPO3-english] Extbase - working with translation
Hi,
I need to work with a translation of a record, but ExtBase loads record
with UID of the translation, I always get the default language. Is there
a setting or something to surpress this behavior?
What I'm trying to do is to translate records in FE, but when I get
translation, update it and save it, the original is updated and not the
translation.
Jan
_______________________________________________
TYPO3-english mailing list
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
Loading...