Permalink
Browse files

MINOR Switching _t() calls from sprintf() to using injection paramete…

…rs (#7170)
  • Loading branch information...
chillu committed May 1, 2012
1 parent 63cef2a commit 38f1236b1f830488d14d6312e78a3aab3cb6e027
@@ -492,7 +492,11 @@ public function deleteunusedthumbnails($request) {
}
}
- $message = sprintf(_t('AssetAdmin.THUMBSDELETED', '%s unused thumbnails have been deleted'), $count);
+ $message = _t(
+ 'AssetAdmin.THUMBSDELETED',
+ '{count} unused thumbnails have been deleted',
+ array('count' => $count)
+ );
$this->response->addHeader('X-Status', $message);
return;
}
@@ -594,7 +598,7 @@ function providePermissions() {
$title = _t("AssetAdmin.MENUTITLE", LeftAndMain::menu_title_for_class($this->class));
return array(
"CMS_ACCESS_AssetAdmin" => array(
- 'name' => sprintf(_t('CMSMain.ACCESS', "Access to '%s' section"), $title),
+ 'name' => _t('CMSMain.ACCESS', "Access to '{title}' section", array('title' => $title)),
'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
)
);
@@ -790,13 +790,11 @@ public function save($data, $form) {
$this->response->addHeader(
'X-Status',
- sprintf(
- _t(
- 'LeftAndMain.STATUSPUBLISHEDSUCCESS',
- "Published '%s' successfully",
- 'Status message after publishing a page, showing the page title'
- ),
- $record->Title
+ _t(
+ 'LeftAndMain.STATUSPUBLISHEDSUCCESS',
+ "Published '{title}' successfully",
+ 'Status message after publishing a page, showing the page title',
+ array('title' => $record->Title)
)
);
} else {
@@ -880,16 +878,16 @@ public function deletefromlive($data, $form) {
if(isset($descendantsRemoved)) {
$descRemoved = " and $descendantsRemoved descendants";
- $descRemoved = sprintf(' '._t('CMSMain.DESCREMOVED', 'and %s descendants'), $descendantsRemoved);
+ $descRemoved = ' ' . _t('CMSMain.DESCREMOVED', 'and {count} descendants', array('count' => $descendantsRemoved));
} else {
$descRemoved = '';
}
$form->sessionMessage(
- sprintf(
- _t('CMSMain.REMOVED', 'Deleted \'%s\'%s from live site'),
- $recordTitle,
- $descRemoved
+ _t(
+ 'CMSMain.REMOVED',
+ 'Deleted \'{title}\'{additionalinfo} from live site',
+ array('title' => $recordTitle, 'additionalinfo' => $descRemoved)
),
'good'
);
@@ -936,9 +934,11 @@ public function revert($data, $form) {
$this->response->addHeader(
'X-Status',
- sprintf(
- _t('CMSMain.RESTORED',"Restored '%s' successfully",'Param %s is a title'),
- $record->Title
+ _t(
+ 'CMSMain.RESTORED',
+ "Restored '{title}' successfully",
+ 'Param %s is a title',
+ array('title' => $record->Title)
)
);
@@ -963,10 +963,7 @@ public function delete($data, $form) {
$record->delete();
$form->sessionMessage(
- sprintf(
- _t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"),
- $record->Title
- ),
+ _t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '{title}' from the draft site", array('title' => $record->Title)),
'good'
);
@@ -991,7 +988,7 @@ function unpublish($data, $form) {
$this->response->addHeader(
'X-Status',
- sprintf(_t('CMSMain.REMOVEDPAGE',"Removed '%s' from the published site"),$record->Title)
+ _t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title))
);
return $this->getResponseNegotiator()->respond($this->request);
@@ -1026,16 +1023,16 @@ function doRollback($data, $form) {
if($version) {
$record->doRollbackTo($version);
- $message = sprintf(
- _t('CMSMain.ROLLEDBACKVERSION',"Rolled back to version #%d. New version number is #%d"),
- $data['Version'],
- $record->Version
+ $message = _t(
+ 'CMSMain.ROLLEDBACKVERSION',
+ "Rolled back to version #%d. New version number is #%d",
+ array('version' => $data['Version'], 'versionnew' => $record->Version)
);
} else {
$record->doRollbackTo('Live');
- $message = sprintf(
- _t('CMSMain.ROLLEDBACKPUB',"Rolled back to published version. New version number is #%d"),
- $record->Version
+ $message = _t(
+ 'CMSMain.ROLLEDBACKPUB',"Rolled back to published version. New version number is #{version}",
+ array('version' => $record->Version)
);
}
@@ -1150,7 +1147,7 @@ function publishall($request) {
break;
}
}
- $response .= sprintf(_t('CMSMain.PUBPAGES',"Done: Published %d pages"), $count);
+ $response .= _t('CMSMain.PUBPAGES',"Done: Published {count} pages", array('count' => $count));
} else {
$token = SecurityToken::inst();
@@ -1188,9 +1185,10 @@ function restore($data, $form) {
$this->response->addHeader(
'X-Status',
- sprintf(
- _t('CMSMain.RESTORED',"Restored '%s' successfully",'Param %s is a title'),
- $restoredPage->TreeTitle
+ _t(
+ 'CMSMain.RESTORED',
+ "Restored '{title}' successfully",
+ array('title' => $restoredPage->TreeTitle)
)
);
@@ -1268,7 +1266,7 @@ function providePermissions() {
$title = _t("CMSPagesController.MENUTITLE", LeftAndMain::menu_title_for_class('CMSPagesController'));
return array(
"CMS_ACCESS_CMSMain" => array(
- 'name' => sprintf(_t('CMSMain.ACCESS', "Access to '%s' section"), $title),
+ 'name' => _t('CMSMain.ACCESS', "Access to '{title}' section", array('title' => $title)),
'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access'),
'help' => _t(
'CMSMain.ACCESS_HELP',
@@ -99,17 +99,22 @@ function getEditForm($id = null, $fields = null, $versionID = null, $compareID =
$view = _t('CMSPageHistoryController.VIEW',"view");
- $message = sprintf(
- _t('CMSPageHistoryController.COMPARINGVERSION',"Comparing versions %s and %s."),
- sprintf('%s (<a href="%s">%s</a>)', $versionID, Controller::join_links($link, $versionID), $view),
- sprintf('%s (<a href="%s">%s</a>)', $compareID, Controller::join_links($link, $compareID), $view)
+ $message = _t(
+ 'CMSPageHistoryController.COMPARINGVERSION',
+ "Comparing versions {version1} and {version2}.",
+ array(
+ 'version1' => sprintf('%s (<a href="%s">%s</a>)', $versionID, Controller::join_links($link, $versionID), $view),
+ 'version2' => sprintf('%s (<a href="%s">%s</a>)', $compareID, Controller::join_links($link, $compareID), $view)
+ )
);
$revert->setReadonly(true);
}
else {
- $message = sprintf(
- _t('CMSPageHistoryController.VIEWINGVERSION',"Currently viewing version %s."), $versionID
+ $message = _t(
+ 'CMSPageHistoryController.VIEWINGVERSION',
+ "Currently viewing version {version}.",
+ array('version' => $versionID)
);
}
@@ -140,7 +140,7 @@ function providePermissions() {
$title = _t("ReportAdmin.MENUTITLE", LeftAndMain::menu_title_for_class($this->class));
return array(
"CMS_ACCESS_ReportAdmin" => array(
- 'name' => sprintf(_t('CMSMain.ACCESS', "Access to '%s' section"), $title),
+ 'name' => _t('CMSMain.ACCESS', "Access to '{title}' section", array('title' => $title)),
'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
)
);
View
@@ -204,12 +204,10 @@ function doPublish() {
fwrite($fh, $errorContent);
fclose($fh);
} else {
- $fileErrorText = sprintf(
- _t(
- "ErrorPage.ERRORFILEPROBLEM",
- "Error opening file \"%s\" for writing. Please check file permissions."
- ),
- $errorFile
+ $fileErrorText = _t(
+ "ErrorPage.ERRORFILEPROBLEM",
+ "Error opening file \"{filename}\" for writing. Please check file permissions.",
+ array('filename' => $errorFile)
);
$this->response->addHeader('X-Status', $fileErrorText);
return $this->httpError(405);
View
@@ -1495,14 +1495,10 @@ function validate() {
if($subject->ID && !in_array($subject->ClassName, $allowed)) {
$result->error(
- sprintf(
- _t(
- 'SiteTree.PageTypeNotAllowed',
- 'Page type "%s" not allowed as child of this parent page',
-
- 'First argument is a class name'
- ),
- $subject->i18n_singular_name()
+ _t(
+ 'SiteTree.PageTypeNotAllowed',
+ 'Page type "{type}" not allowed as child of this parent page',
+ array('type' => $subject->i18n_singular_name())
),
'ALLOWED_CHILDREN'
);
@@ -1512,14 +1508,10 @@ function validate() {
// "Can be root" validation
if(!$this->stat('can_be_root') && !$this->ParentID) {
$result->error(
- sprintf(
- _t(
- 'SiteTree.PageTypNotAllowedOnRoot',
- 'Page type "%s" is not allowed on the root level',
-
- 'First argument is a class name'
- ),
- $this->i18n_singular_name()
+ _t(
+ 'SiteTree.PageTypNotAllowedOnRoot',
+ 'Page type "{type}" is not allowed on the root level',
+ array('type' => $this->i18n_singular_name())
),
'CAN_BE_ROOT'
);
@@ -1781,9 +1773,10 @@ function getCMSFields() {
. $parentList;
}
- $statusMessage[] = sprintf(
- _t('SiteTree.APPEARSVIRTUALPAGES', "This content also appears on the virtual pages in the %s sections."),
- $parentList
+ $statusMessage[] = _t(
+ 'SiteTree.APPEARSVIRTUALPAGES',
+ "This content also appears on the virtual pages in the {title} sections.",
+ array('title' => $parentList)
);
}
}
View
@@ -301,14 +301,10 @@ function validate() {
$orig = $this->CopyContentFrom();
if(!$orig->stat('can_be_root') && !$this->ParentID) {
$result->error(
- sprintf(
- _t(
- 'VirtualPage.PageTypNotAllowedOnRoot',
- 'Original page type "%s" is not allowed on the root level for this virtual page',
-
- 'First argument is a class name'
- ),
- $orig->i18n_singular_name()
+ _t(
+ 'VirtualPage.PageTypNotAllowedOnRoot',
+ 'Original page type "{type}" is not allowed on the root level for this virtual page',
+ array('type' => $orig->i18n_singular_name())
),
'CAN_BE_ROOT_VIRTUAL'
);
@@ -50,9 +50,10 @@ function forTemplate() {
$result .= "</ul>\n";
} else {
$result = "<p class=\"message notice\">" .
- sprintf(
- _t('SideReport.REPEMPTY','The %s report is empty.','%s is a report title'),
- $this->report->title()
+ _t(
+ 'SideReport.REPEMPTY',
+ 'The {title} report is empty.',
+ array('title' => $this->report->title())
)
. "</p>";
}
Oops, something went wrong.

0 comments on commit 38f1236

Please sign in to comment.