Skip to content

Commit

Permalink
Translations
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervanscheepen committed Jul 30, 2022
1 parent 3cb6705 commit c6c89d3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
7 changes: 7 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
en:
Hamaka\TaskForms\Controllers\GroupedTaskRunner:
CAT_PRIORITY_LABEL: 'Priority'
CAT_STATS_AND_REPORTS_LABEL: 'Statistics and reports'
CAT_MAINTENANCE_LABEL: 'Maintenance'
CAT_TESTS_LABEL: 'Tests'
CAT_OTHER_LABEL: 'Misc'
7 changes: 7 additions & 0 deletions lang/nl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nl:
Hamaka\TaskForms\Controllers\GroupedTaskRunner:
CAT_PRIORITY_LABEL: 'Prioriteit'
CAT_STATS_AND_REPORTS_LABEL: 'Statistieken en rapportages'
CAT_MAINTENANCE_LABEL: 'Onderhoud'
CAT_TESTS_LABEL: 'Tests'
CAT_OTHER_LABEL: 'Overig'
19 changes: 6 additions & 13 deletions src/Controllers/GroupedTaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use SilverStripe\Dev\DebugView;
use SilverStripe\Dev\TaskRunner;
use SilverStripe\Dev\TestOnly;
use function _t;
use function in_array;
use function is_array;
use function singleton;
Expand Down Expand Up @@ -120,45 +121,37 @@ public function getCategories()
*/
$aRemovedCategories = (array)$oConfig->get('removed_categories');

/**
* YML:
* SilverStripe\Dev\TaskRunner:
* category_names:
* TASK_CAT_OTHER: 'Not specified'
*/
$aCategoriesNames = (array)$oConfig->get('category_names');

if ( ! in_array(static::TASK_CAT_PRIORITY, $aRemovedCategories)) {
$aAllCategories[static::TASK_CAT_PRIORITY] = [
'name' => $aCategoriesNames[static::TASK_CAT_PRIORITY] ?? 'Top of the list',
'name' => _t('Hamaka\\TaskForms\\Controllers\\GroupedTaskRunner.CAT_PRIORITY_LABEL', "Priority"),
'sort' => 100,
];
}

if ( ! in_array(static::TASK_CAT_STATS_AND_REPORTS, $aRemovedCategories)) {
$aAllCategories[static::TASK_CAT_STATS_AND_REPORTS] = [
'name' => $aCategoriesNames[static::TASK_CAT_STATS_AND_REPORTS] ?? 'Statistics and Reports',
'name' => _t('Hamaka\\TaskForms\\Controllers\\GroupedTaskRunner.CAT_STATS_AND_REPORTS_LABEL', "Statistics and Reports"),
'sort' => 90,
];
}

if ( ! in_array(static::TASK_CAT_MAINTENANCE, $aRemovedCategories)) {
$aAllCategories[static::TASK_CAT_MAINTENANCE] = [
'name' => $aCategoriesNames[static::TASK_CAT_MAINTENANCE] ?? 'Maintenance',
'name' => _t('Hamaka\\TaskForms\\Controllers\\GroupedTaskRunner.CAT_MAINTENANCE_LABEL', "Maintenance"),
'sort' => 70,
];
}

if ( ! in_array(static::TASK_CAT_TESTS, $aRemovedCategories)) {
$aAllCategories[static::TASK_CAT_TESTS] = [
'name' => $aCategoriesNames[static::TASK_CAT_TESTS] ?? 'Tests',
'name' => _t('Hamaka\\TaskForms\\Controllers\\GroupedTaskRunner.CAT_TESTS_LABEL', "Tests"),
'sort' => 50,
];
}

if ( ! in_array(static::TASK_CAT_OTHER, $aRemovedCategories)) {
$aAllCategories[static::TASK_CAT_OTHER] = [
'name' => $aCategoriesNames[static::TASK_CAT_OTHER] ?? 'Misc',
'name' => _t('Hamaka\\TaskForms\\Controllers\\GroupedTaskRunner.A', "Misc"),
'sort' => 10,
];
}
Expand Down
4 changes: 2 additions & 2 deletions src/ExampleTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function run($request = null)
{
// this adds CSS to the task
TaskUtil::makePretty();

// echoNormal, echoGood, echoNotice, echoError and echoCommentOnPrev are shorthands
// for styled messages like DB::alteration_message('Something is wrong', TaskUtil::ALT_MESSAGE_TYPE_ERROR);
TaskUtil::echoNormal("Start task " . $this->title);
Expand All @@ -39,7 +39,7 @@ public function run($request = null)
// the & is important.
$aGetKeyToVarMap = [
'MemberID' => &$iMemberID,
'New FirstName' => &$sFirstName
'New_FirstName' => &$sFirstName
];

// which fields are required to execute the task?
Expand Down
15 changes: 7 additions & 8 deletions src/Utils/TaskUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
use function is_string;
use function method_exists;
use function print_r;
use function str_replace;
use function time;

/**
* @todo TaskRunner
* @todo is er JS toe te voegen die zodra je 1 veld aanpast het execute veld weghaalt? Dus dat je bij een wijziging geforceerd wordt om nog een dry run te starten.
*/

/**
* Utility functions to make Silverstripe Tasks
*
Expand Down Expand Up @@ -296,6 +292,7 @@ public static function getFormHTML($aGetKeyToVarMap = [], $aRequiredFieldsNamesA
$aHTML[] = '<form action="" method="get" >';

foreach ($aGetKeyToVarMap as $sGetKey => &$sVar) {
$sFieldLabel = str_replace('_', ' ', $sGetKey);
if ( ! is_string($sVar)) {
$sVar = '';
}
Expand All @@ -310,12 +307,12 @@ public static function getFormHTML($aGetKeyToVarMap = [], $aRequiredFieldsNamesA
$aCustomComponents[$sGetKey]->setValue($sVar);
}

$aHTML[] = '<span class=\'fieldlabel\'>' . $sGetKey . ':</span><br/>';
$aHTML[] = '<span class=\'fieldlabel\'>' . $sFieldLabel . ':</span><br/>';
$aHTML[] = $aCustomComponents[$sGetKey]->forTemplate() . '<br/><br/>';
}
}
else {
$aHTML[] = '<span class=\'fieldlabel\'>' . $sGetKey . ':</span><br/>';
$aHTML[] = '<span class=\'fieldlabel\'>' . $sFieldLabel . ':</span><br/>';
$aHTML[] = '<input type="text" name="' . $sGetKey . '" value="' . $sVar . '" "><br/><br/>';
}
}
Expand Down Expand Up @@ -375,7 +372,8 @@ public static function getResetFormHTML()

public static function addConfetti()
{
echo '
if (Director::is_cli() !== true) {
echo '
<script>var confetti = {
maxCount: 100, //set max confetti count
speed: 2, //set the particle animation speed
Expand Down Expand Up @@ -599,6 +597,7 @@ function updateParticles() {
})();
</script>';
}
}

public static function echoArrayAsTable($aData, $bShowHeaders = true, $sLayOut = 'horizontal')
Expand Down

0 comments on commit c6c89d3

Please sign in to comment.