enupal / translate

Translate your website templates and plugins into multiple languages for Craft CMS. Bulk translation with Google Translate or Yandex.
https://enupal.com/craft-plugins/translate
Other
10 stars 2 forks source link

Question: Is there a way programatically run "Sync with DB"? #51

Closed circa1983 closed 2 years ago

circa1983 commented 2 years ago

Description

Is there a way to programatically run “Sync with DB” via craft cli (console command) or via a shell or php script?

We host our sites on Servd, which uses atomic deployment for all of its sites, this means whenever we update anything (Craft version, plugin updates, template changes, etc), a new environment is created and our static translations are lost!

Enupal Translate’s brilliant feature “Sync with DB” fixes this, allowing us to apply the static translations to the new instance but it’s a manual step. This means sites that have been automatically updated don’t have the static translations and if the sync isn’t performed before the next deployment, we totally loose the translations.

Servd offers “Post Deploy Tasks” so if you have a Custom Console Command specific to the enupal-translate plugin that would be ideal!

Failing that, a method which we could access via a module (so we can to create a console command our selves) would suffice.

Many thanks, Sam.

Additional info

andrelopez commented 2 years ago

Hi @circa1983 Thanks for reaching out. The following line will add the translate sync to the job queue

use enupal\translate\Translate;
...

Translate::$app->translate->runSync();

Make sure to run queue/run console command to make sure the job is executed

circa1983 commented 2 years ago

Hi @andrelopez,

Many thanks for the fast response and thank you for the code snippet, it’s really helpful.