Skip to content
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

FIX Remove legacy translation behaviour in template #78

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions code/GroupImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,31 @@ public function __construct($controller, $name, $fields = null, $actions = null,
{
if (!$fields) {
$helpHtml = _t(
'SilverStripe\\Admin\\GroupImportForm.Help1',
__CLASS__ . '.Help1',
'<p>Import one or more groups in <em>CSV</em> format (comma-separated values).'
. ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
);

$importer = new GroupCsvBulkLoader();
$importSpec = $importer->getImportSpec();

$columns = implode(', ', array_keys($importSpec['fields']));
$helpHtml .= _t(
'SilverStripe\\Admin\\GroupImportForm.Help2',
__CLASS__ . '.Help2',
'<div class="advanced">'
. '<h4>Advanced usage</h4>'
. '<ul>'
. '<li>Allowed columns: <em>%s</em></li>'
. '<li>Allowed columns: <em>{columns}</em></li>'
. '<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the '
. 'imported file</li>'
. '<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>'
. '<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not '
. 'cleared.</li>'
. '</ul>'
. '</div>'
. '</div>',
array('columns' => $columns)
);

$importer = new GroupCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));

$fields = new FieldList(
new LiteralField('Help', $helpHtml),
$fileField = new FileField(
Expand Down Expand Up @@ -91,22 +93,22 @@ public function doImport($data, $form)
$msgArr = array();
if ($result->CreatedCount()) {
$msgArr[] = _t(
'SilverStripe\\Admin\\GroupImportForm.ResultCreated',
__CLASS__ . '.ResultCreated',
'Created {count} groups',
array('count' => $result->CreatedCount())
);
}
if ($result->UpdatedCount()) {
$msgArr[] = _t(
'SilverStripe\\Admin\\GroupImportForm.ResultUpdated',
'Updated %d groups',
__CLASS__ . '.ResultUpdated',
'Updated {count} groups',
array('count' => $result->UpdatedCount())
);
}
if ($result->DeletedCount()) {
$msgArr[] = _t(
'SilverStripe\\Admin\\GroupImportForm.ResultDeleted',
'Deleted %d groups',
__CLASS__ . '.ResultDeleted',
'Deleted {count} groups',
array('count' => $result->DeletedCount())
);
}
Expand Down
28 changes: 15 additions & 13 deletions code/MemberImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,30 @@ public function __construct($controller, $name, $fields = null, $actions = null,
{
if (!$fields) {
$helpHtml = _t(
'SilverStripe\\Admin\\MemberImportForm.Help1',
__CLASS__ . '.Help1',
'<p>Import users in <em>CSV format</em> (comma-separated values).'
. ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
);

$importer = new MemberCsvBulkLoader();
$importSpec = $importer->getImportSpec();

$columns = implode(', ', array_keys($importSpec['fields']));
$helpHtml .= _t(
'SilverStripe\\Admin\\MemberImportForm.Help2',
__CLASS__ . '.Help2',
'<div class="advanced">'
. '<h4>Advanced usage</h4>'
. '<ul>'
. '<li>Allowed columns: <em>%s</em></li>'
. '<li>Allowed columns: <em>{columns}</em></li>'
. '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from '
. 'the imported file.</li>'
. '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, '
. 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>'
. '</ul>'
. '</div>'
. '</div>',
array('columns' => $columns)
);

$importer = new MemberCsvBulkLoader();
$importSpec = $importer->getImportSpec();
$helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));

$fields = new FieldList(
new LiteralField('Help', $helpHtml),
$fileField = new FileField(
Expand Down Expand Up @@ -100,26 +102,26 @@ public function doImport($data, $form)
$msgArr = array();
if ($result->CreatedCount()) {
$msgArr[] = _t(
'SilverStripe\\Admin\\MemberImportForm.ResultCreated',
__CLASS__ . '.ResultCreated',
'Created {count} members',
array('count' => $result->CreatedCount())
);
}
if ($result->UpdatedCount()) {
$msgArr[] = _t(
'SilverStripe\\Admin\\MemberImportForm.ResultUpdated',
__CLASS__ . '.ResultUpdated',
'Updated {count} members',
array('count' => $result->UpdatedCount())
);
}
if ($result->DeletedCount()) {
$msgArr[] = _t(
'SilverStripe\\Admin\\MemberImportForm.ResultDeleted',
'Deleted %d members',
__CLASS__ . '.ResultDeleted',
'Deleted {count} members',
array('count' => $result->DeletedCount())
);
}
$msg = ($msgArr) ? implode(',', $msgArr) : _t('SilverStripe\\Admin\\MemberImportForm.ResultNone', 'No changes');
$msg = ($msgArr) ? implode(',', $msgArr) : _t(__CLASS__ . '.ResultNone', 'No changes');

$this->sessionMessage($msg, 'good');

Expand Down
14 changes: 7 additions & 7 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ en:
URL: URL
SilverStripe\Admin\GroupImportForm:
Help1: '<p>Import one or more groups in <em>CSV</em> format (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
Help2: '<div class="advanced"><h4>Advanced usage</h4><ul><li>Allowed columns: <em>%s</em></li><li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the imported file</li><li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li><li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not cleared.</li></ul></div>'
Help2: '<div class="advanced"><h4>Advanced usage</h4><ul><li>Allowed columns: <em>{columns}</em></li><li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the imported file</li><li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li><li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not cleared.</li></ul></div>'
ResultCreated: 'Created {count} groups'
ResultDeleted: 'Deleted %d groups'
ResultUpdated: 'Updated %d groups'
ResultDeleted: 'Deleted {count} groups'
ResultUpdated: 'Updated {count} groups'
SilverStripe\Admin\LeftAndMain:
ACCESSALLINTERFACES: 'Access to all CMS sections'
ACCESSALLINTERFACESHELP: 'Overrules more specific access settings.'
Expand Down Expand Up @@ -60,9 +60,9 @@ en:
BtnImport: 'Import from CSV'
FileFieldLabel: 'CSV File <small>(Allowed extensions: *.csv)</small>'
Help1: '<p>Import users in <em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
Help2: '<div class="advanced"><h4>Advanced usage</h4><ul><li>Allowed columns: <em>%s</em></li><li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li><li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, multiple groups can be separated by comma. Existing group memberships are not cleared.</li></ul></div>'
Help2: '<div class="advanced"><h4>Advanced usage</h4><ul><li>Allowed columns: <em>{columns}</em></li><li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li><li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, multiple groups can be separated by comma. Existing group memberships are not cleared.</li></ul></div>'
ResultCreated: 'Created {count} members'
ResultDeleted: 'Deleted %d members'
ResultDeleted: 'Deleted {count} members'
ResultNone: 'No changes'
ResultUpdated: 'Updated {count} members'
SilverStripe\Admin\ModelAdmin:
Expand All @@ -74,9 +74,9 @@ en:
IMPORT: 'Import from CSV'
IMPORTEDRECORDS: 'Imported {count} records.'
IMPORTSPECFIELDS: 'Database columns'
IMPORTSPECLINK: 'Show Specification for %s'
IMPORTSPECLINK: 'Show Specification for {model}'
IMPORTSPECRELATIONS: Relations
IMPORTSPECTITLE: 'Specification for %s'
IMPORTSPECTITLE: 'Specification for {model}'
NOCSVFILE: 'Please browse for a CSV file to import'
NOIMPORT: 'Nothing to import'
RESET: Reset
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="importSpec" id="SpecFor{$ClassName}">
<a href="#SpecDetailsFor{$ClassName}" class="detailsLink"><% sprintf(_t('SilverStripe\Admin\ModelAdmin.IMPORTSPECLINK', 'Show Specification for %s'),$ModelName) %></a>
<a href="#SpecDetailsFor{$ClassName}" class="detailsLink"><%t SilverStripe\Admin\ModelAdmin.IMPORTSPECLINK 'Show Specification for {model}' model=$ModelName %></a>
<div class="details" id="SpecDetailsFor{$ClassName}">
<h4><% sprintf(_t('SilverStripe\Admin\ModelAdmin.IMPORTSPECTITLE', 'Specification for %s'),$ModelName) %></h4>
<h5><% _t('SilverStripe\Admin\ModelAdmin.IMPORTSPECFIELDS', 'Database columns') %></h5>
<h4><%t SilverStripe\Admin\ModelAdmin.IMPORTSPECTITLE 'Specification for {model}' model=$ModelName %></h4>
<h5><%t SilverStripe\Admin\ModelAdmin.IMPORTSPECFIELDS 'Database columns' %></h5>
<% loop $Fields %>
<dl>
<dt><em>$Name</em></dt>
Expand Down