-
Notifications
You must be signed in to change notification settings - Fork 23
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
[FEATURE]: Automatic translation or execute using cron? #284
Comments
Hi @Pandan and thanks for your question. You can take inspiration on how it is done in plugin/server/controllers/translate.js. Currently the easier way is to do the batch translation. Direct works as well but the service is currently only written to translate individual fields and you need to import the utils manually. We will probably improve that at some point though Batch Translation would look like this: await getService('translate').batchTranslate({
contentType: "api::article.article",
// Use here the exact id of the locale you selected in the internationalization settings in strapi
sourceLocale: "en-US",
targetLocale: "de",
// Optional, use to specify the individual ones to translate,
// otherwise all currently untranslated ones will be translated
entityIds: [1,2,3],
autoPublish: true,
}), |
@sargreal Thank you for the quick response, I'll take a look and see if I can figure something out :) |
@Pandan Did you find any solution for the automation? |
@hadiulofficial Yes, i did follow @sargreal advice and it worked great.
|
@Pandan Where u ran this code could u please tell? did u crated any new file or could u please tell the way |
Dear @hadiulofficial, The cron option (for creating batch translations at a fixed time) is described in the strapi docs: https://docs.strapi.io/dev-docs/configurations/cron If you want to run this translation directly after a content is created or updated, you will need to use the lifecycle hooks, described here in the strapi docs: https://docs.strapi.io/dev-docs/backend-customization/models#lifecycle-hooks |
Hi,
I am wondering if there is someway to automate a translation or execute a batch using a cron job .
In our Strapi setup we are fetching data from an external api which then populates a collection-type in strapi.
This fetching is done regularly using a cron job.
It would be great If I somehow could translate each entry automatically when its added or trigger a batch when all enteries has been added?
The text was updated successfully, but these errors were encountered: