Skip to content

Commit

Permalink
Globalisation, transifex support
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Oct 24, 2013
1 parent c12b200 commit bdc0433
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com

[silverstripe-queuedjobs.master]
file_filter = lang/<lang>.yml
source_file = lang/en.yml
source_lang = en
type = YML
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ cronjob is configured and executing correctly.

ALTER TABLE `QueuedJobDescriptor` ADD INDEX ( `JobStatus` , `JobType` )

## Contributing

### Translations

Translations of the natural language strings are managed through a third party translation interface, transifex.com. Newly added strings will be periodically uploaded there for translation, and any new translations will be merged back to the project source code.

Please use [https://www.transifex.com/projects/p/silverstripe-queuedjobs](https://www.transifex.com/projects/p/silverstripe-queuedjobs) to contribute translations, rather than sending pull requests with YAML files.
6 changes: 5 additions & 1 deletion code/controllers/QueuedJobsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public function getEditForm($id = null, $fields = null) {
$list = DataList::create('QueuedJobDescriptor');
$list = $list->where($filter);

$grid = new GridField('QueuedJobDescriptor', 'Jobs', $list);
$grid = new GridField(
'QueuedJobDescriptor',
_t('QueuedJobs.JobsFieldTitle','Jobs'),
$list
);
$grid->setForm($form);

$form->Fields()->replaceField('QueuedJobDescriptor', $grid);
Expand Down
14 changes: 13 additions & 1 deletion code/extensions/ScheduledExecutionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ class ScheduledExecutionExtension extends DataExtension {
public function updateCMSFields(FieldList $fields) {
$fields->addFieldsToTab('Root.Schedule', array(
$dt = new Datetimefield('FirstExecution', _t('ScheduledExecution.FIRST_EXECUTION', 'First Execution')),
new DropdownField('ExecuteEvery', _t('ScheduledExecution.EXECUTE_EVERY', 'Execute every'), $this->owner->dbObject('ExecuteEvery')->enumValues()),
new DropdownField(
'ExecuteEvery',
_t('ScheduledExecution.EXECUTE_EVERY', 'Execute every'),
array(
'' => '',
'Hour' => _t('ScheduledExecution.ExecuteEveryHour', 'Hour'),
'Day' => _t('ScheduledExecution.ExecuteEveryDay', 'Day'),
'Week' => _t('ScheduledExecution.ExecuteEveryWeek', 'Week'),
'Fortnight' => _t('ScheduledExecution.ExecuteEveryFortnight', 'Fortnight'),
'Month' => _t('ScheduledExecution.ExecuteEveryMonth', 'Month'),
'Year' => _t('ScheduledExecution.ExecuteEveryYear', 'Year'),
)
),
new TextField('ExecuteFree', _t('ScheduledExecution.EXECUTE_FREE','Scheduled (in strtotime format from first execution)'))
));

Expand Down
2 changes: 1 addition & 1 deletion code/jobs/DeleteObjectJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getJobType() {
public function getTitle() {
$obj = $this->getObject();
if ($obj) {
return _t('DeleteObjectJob.DELETE_OBJ', 'Delete ' . $obj->Title);
return _t('DeleteObjectJob.DELETE_OBJ2', 'Delete {title}', array('title' => $obj->Title));
} else {
return _t('DeleteObjectJob.DELETE_JOB', 'Delete node');
}
Expand Down
6 changes: 5 additions & 1 deletion code/jobs/PublishItemsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ protected function getRoot() {
}

public function getTitle() {
return "Publish items beneath " . $this->getRoot()->Title;
return _t(
'PublishItemsJob.Title',
"Publish items beneath {title}",
array('title' => $this->getRoot()->Title)
);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion code/jobs/ScheduledExecutionJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public function getDataObject() {
}

public function getTitle() {
return 'Scheduled execution for '.$this->getDataObject()->getTitle();
return _t(
'ScheduledExecutionJob.Title',
'Scheduled execution for {title}',
array('title' => $this->getDataObject()->getTitle())
);
}


Expand Down
9 changes: 7 additions & 2 deletions code/tasks/CreateQueuedJobTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
* @license BSD http://silverstripe.org/bsd-license/
*/
class CreateQueuedJobTask extends BuildTask {

protected $description = 'A task used to create a queued job. Pass the queued job class name as the "name" parameter, pass an optional "start" parameter (parseable by strtotime) to set a start time for the job.';

public function getDescription() {
return _t(
'CreateQueuedJobTask.Description',
'A task used to create a queued job. Pass the queued job class name as the "name" parameter, pass an optional "start" parameter (parseable by strtotime) to set a start time for the job.'
);
}

public function run($request) {
if (isset($request['name']) && ClassInfo::exists($request['name'])) {
Expand Down
7 changes: 6 additions & 1 deletion code/tasks/ProcessJobQueueTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
*/
class ProcessJobQueueTask extends BuildTask {

protected $description = 'Used via a cronjob to execute queued jobs that need running';
public function getDescription() {
return _t(
'ProcessJobQueueTask.Description',
'Used via a cronjob to execute queued jobs that need running'
);
}

public function run($request) {
$service = singleton('QueuedJobService');
Expand Down
47 changes: 47 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
en:
QueuedJobsAdmin:
MENUTITLE: Jobs
CreateQueuedJobTask:
Description: 'A task used to create a queued job. Pass the queued job class name as the "name" parameter, pass an optional "start" parameter (parseable by strtotime) to set a start time for the job.'
DeleteObjectJob:
DELETE_JOB: 'Delete node'
DELETE_OBJ2: 'Delete {title}'
GenerateSitemapJob:
REGENERATE: 'Regenerate Google sitemap .xml file'
ProcessJobQueueTask:
Description: 'Used via a cronjob to execute queued jobs that need running'
PublishItemsJob:
Title: 'Publish items beneath {title}'
QueuedJobDescriptor:
PLURALNAME: 'Queued Job Descriptors'
SINGULARNAME: 'Queued Job Descriptor'
QueuedJobs:
JOB_EXCEPT: 'Job caused exception %s in %s at line %s'
JOB_PAUSED: 'Job paused at %s'
JOB_STALLED: 'Job stalled after %s attempts - please check'
JOB_TYPE: 'Job Type'
JobsFieldTitle: Jobs
MEMORY_RELEASE: 'Job releasing memory and waiting (%s used)'
STALLED_JOB: 'Stalled job'
STALLED_JOB_MSG: 'A job named %s appears to have stalled. It has been paused, please login to check it'
TABLE_ADDE: Added
TABLE_MESSAGES: Message
TABLE_NUM_PROCESSED: Done
TABLE_STARTED: Started
TABLE_START_AFTER: 'Start After'
TABLE_STATUS: Status
TABLE_TITLE: Title
TABLE_TOTAL: Total
ScheduledExecution:
EXECUTE_EVERY: 'Execute every'
EXECUTE_FREE: 'Scheduled (in strtotime format from first execution)'
ExecuteEveryDay: Day
ExecuteEveryFortnight: Fortnight
ExecuteEveryHour: Hour
ExecuteEveryMonth: Month
ExecuteEveryWeek: Week
ExecuteEveryYear: Year
FIRST_EXECUTION: 'First Execution'
NEXT_RUN_DATE: 'Next run date'
ScheduledExecutionJob:
Title: 'Scheduled execution for {title}'

0 comments on commit bdc0433

Please sign in to comment.