Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Translation Import for single records #344

Open
bh-teufels opened this issue Sep 20, 2024 · 4 comments
Open

Question: Translation Import for single records #344

bh-teufels opened this issue Sep 20, 2024 · 4 comments
Labels

Comments

@bh-teufels
Copy link

I have the following requirements:

I have imported datasets (svconnector_json). However, the translations for these datasets require an API call (JSON), where the ID of each individual record is needed.
So for the import of translations, I have to execute this call "individually" for each record.
How can this be solved?

Thank you for your help.

@fsuter
Copy link
Contributor

fsuter commented Sep 20, 2024

I had a somewhat similar need in the past. What I did was to use External Import as an API (as described here: https://docs.typo3.org/p/cobweb/external_import/7.2/en-us/Developer/Api/Index.html#developer-api-import), in effect calling itself. This could be within a user function or within a custom step, depending on your needs. It could also be in the DatamapPostprocess event (https://docs.typo3.org/p/cobweb/external_import/7.2/en-us/Developer/Events/Index.html#developer-events-datamap-postprocess), since you would have the list of all records imported in the original language.

@bh-teufels
Copy link
Author

Thank you.

What I can retrieve via the API are all available translations for all records (including closed ones), which is significantly more than I initially imported.
If I interpret this correctly, one option would be to use the insert record preprocess to only create translations for records where a record in the default language already exists. Am I understanding this correctly?

A single API call for all translations would likely be faster than 1,000 individual calls, despite the result containing significantly more records.

@fsuter
Copy link
Contributor

fsuter commented Sep 20, 2024

It is definitely faster to retrieve all translations in one go. It's just a question of knowing where to store them until you use each of them. For this, a custom step would be the right place, because the "data" object provides an "ExtraData" array for storing whatever you need, and the data object is passed along to each step. And IIRC if you register a custom step after the StoreDataStep, it should have a list of all records that were handled so far. i.e. the list of records in the original language.

If you want to create translations only for newly imported records, then you need to use the insert record preprocess event indeed.

@bh-teufels
Copy link
Author

Thank you, I'll take a look at which approach is best suited for me.
Currently, I'm still clarifying whether I can limit the API call for translations or pass multiple IDs at once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants