diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ee7e9f..bf02210 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,13 +4,8 @@ on: push: pull_request: workflow_dispatch: - # Every Wednesday at 12:00pm UTC - schedule: - - cron: '0 12 * * 3' jobs: ci: name: CI - # Only run cron on the silverstripe account - if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule') uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 diff --git a/.github/workflows/dispatch-ci.yml b/.github/workflows/dispatch-ci.yml new file mode 100644 index 0000000..7605238 --- /dev/null +++ b/.github/workflows/dispatch-ci.yml @@ -0,0 +1,16 @@ +name: Dispatch CI + +on: + # At 12:00 PM UTC, only on Wednesday and Thursday + schedule: + - cron: '0 12 * * 3,4' + +jobs: + dispatch-ci: + name: Dispatch CI + # Only run cron on the silverstripe account + if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule') + runs-on: ubuntu-latest + steps: + - name: Dispatch CI + uses: silverstripe/gha-dispatch-ci@v1 diff --git a/.tx/config b/.tx/config new file mode 100644 index 0000000..68e1f1f --- /dev/null +++ b/.tx/config @@ -0,0 +1,10 @@ +[main] +host = https://www.transifex.com + +[o:silverstripe:p:silverstripe-crontask:r:master] +file_filter = lang/.yml +source_file = lang/en.yml +source_lang = en +type = YML + + diff --git a/lang/_manifest_exclude b/lang/_manifest_exclude new file mode 100644 index 0000000..e69de29 diff --git a/lang/en.yml b/lang/en.yml new file mode 100644 index 0000000..c7778a0 --- /dev/null +++ b/lang/en.yml @@ -0,0 +1,18 @@ +en: + SilverStripe\CronTask\Controllers\CronTaskController: + NO_IMPLEMENTERS: 'There are no implementators of CronTask to run' + WILL_RUN_AT: '{task} will run at {time}.' + WILL_START_NOW: '{task} will start now.' + SilverStripe\CronTask\CronTaskController: + NO_IMPLEMENTERS: 'There are no implementators of CronTask to run' + WILL_RUN_AT: '{task} will run at {time}.' + WILL_START_NOW: '{task} will start now.' + SilverStripe\CronTask\CronTaskStatus: + PLURALNAME: 'Cron Task Statuss' + PLURALS: + one: 'A Cron Task Status' + other: '{count} Cron Task Statuss' + SINGULARNAME: 'Cron Task Status' + db_LastChecked: 'Last checked' + db_LastRun: 'Last run' + db_TaskClass: 'Task class' diff --git a/src/Controllers/CronTaskController.php b/src/Controllers/CronTaskController.php index 5a9e7e7..d80bedb 100644 --- a/src/Controllers/CronTaskController.php +++ b/src/Controllers/CronTaskController.php @@ -110,7 +110,7 @@ public function index(HTTPRequest $request) // Check each task $tasks = ClassInfo::implementorsOf(CronTask::class); if (empty($tasks)) { - $this->output("There are no implementators of CronTask to run", 2); + $this->output(_t(self::class . '.NO_IMPLEMENTERS', 'There are no implementators of CronTask to run'), 2); return; } foreach ($tasks as $subclass) { @@ -134,10 +134,17 @@ public function runTask(CronTask $task) // Update status of this task prior to execution in case of interruption CronTaskStatus::update_status(get_class($task), $isDue); if ($isDue) { - $this->output(get_class($task) . ' will start now.'); + $this->output(_t(self::class . '.WILL_START_NOW', '{task} will start now.', ['task' => get_class($task)])); $task->process(); } else { - $this->output(get_class($task) . ' will run at ' . $cron->getNextRunDate()->format('Y-m-d H:i:s') . '.', 2); + $this->output( + _t( + self::class . '.WILL_RUN_AT', + '{task} will run at {time}.', + ['task' => get_class($task), 'time' => $cron->getNextRunDate()->format('Y-m-d H:i:s')] + ), + 2 + ); } }