Removed direct sprintf() usage from _t() calls

Parameterized strings are easier to understand,
and more fail-proof, don't fatal out when not enough sprintf() args
This commit is contained in:
Ingo Schommer 2012-12-21 11:18:18 +01:00
parent 894d48789c
commit cb96255e80
3 changed files with 27 additions and 12 deletions

View File

@ -927,15 +927,24 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
Versioned::reading_stage('Stage'); Versioned::reading_stage('Stage');
if(isset($descendantsRemoved)) { if(isset($descendantsRemoved)) {
$descRemoved = " and $descendantsRemoved descendants"; $descRemoved = ' ' . _t(
$descRemoved = ' ' . _t('CMSMain.DESCREMOVED', 'and {count} descendants', array('count' => $descendantsRemoved)); 'CMSMain.DESCREMOVED',
'and {count} descendants',
array('count' => $descendantsRemoved)
);
} else { } else {
$descRemoved = ''; $descRemoved = '';
} }
$this->response->addHeader( $this->response->addHeader(
'X-Status', 'X-Status',
rawurlencode(sprintf(_t('CMSMain.REMOVED', 'Deleted \'%s\'%s from live site'), $recordTitle, $descRemoved)) rawurlencode(
_t(
'CMSMain.REMOVED',
'Deleted \'{title}\'{description} from live site',
array('title' => $recordTitle, 'description' => $descRemoved)
)
)
); );
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" // Even if the record has been deleted from stage and live, it can be viewed in "archive mode"

View File

@ -1,6 +1,7 @@
en: en:
AssetAdmin: AssetAdmin:
ADDFILES: 'Add Files' ADDFILES: 'Add Files'
ALLOWEDEXTS: 'Allowed extensions'
ActionAdd: 'Add folder' ActionAdd: 'Add folder'
AppCategoryArchive: Archive AppCategoryArchive: Archive
AppCategoryAudio: Audio AppCategoryAudio: Audio
@ -93,7 +94,7 @@ en:
PUBALLFUN2: "Pressing this button will do the equivalent of going to every page and pressing \"publish\". It's\n intended to be used after there have been massive edits of the content, such as when the site was\n first built." PUBALLFUN2: "Pressing this button will do the equivalent of going to every page and pressing \"publish\". It's\n intended to be used after there have been massive edits of the content, such as when the site was\n first built."
PUBPAGES: 'Done: Published {count} pages' PUBPAGES: 'Done: Published {count} pages'
PageAdded: 'Successfully created page' PageAdded: 'Successfully created page'
REMOVED: 'Deleted ''%s''%s from live site' REMOVED: 'Deleted ''{title}''{description} from live site'
REMOVEDPAGE: 'Removed ''{title}'' from the published site' REMOVEDPAGE: 'Removed ''{title}'' from the published site'
REMOVEDPAGEFROMDRAFT: 'Removed ''%s'' from the draft site' REMOVEDPAGEFROMDRAFT: 'Removed ''%s'' from the draft site'
RESTORE: Restore RESTORE: Restore
@ -138,7 +139,6 @@ en:
MENUTITLE: Pages MENUTITLE: Pages
TreeView: 'Tree View' TreeView: 'Tree View'
CMSPagesController_ContentToolbar.ss: CMSPagesController_ContentToolbar.ss:
ENABLEDRAGGING: 'Drag''n''drop'
MULTISELECT: Multi-selection MULTISELECT: Multi-selection
CMSPagesController_Tools.ss: CMSPagesController_Tools.ss:
FILTER: Filter FILTER: Filter
@ -173,7 +173,7 @@ en:
PUBLISHEDSITE: 'Published Site' PUBLISHEDSITE: 'Published Site'
Password: Password Password: Password
PostInstallTutorialIntro: 'This website is a simplistic version of a SilverStripe 3 site. To extend this, please take a look at {link}.' PostInstallTutorialIntro: 'This website is a simplistic version of a SilverStripe 3 site. To extend this, please take a look at {link}.'
StartEditing: 'You can start editing your site\''s content by opening <a href="{link}">the CMS</a>.' StartEditing: 'You can start editing your content by opening <a href="{link}">the CMS</a>.'
UnableDeleteInstall: 'Unable to delete installation files. Please delete the files below manually' UnableDeleteInstall: 'Unable to delete installation files. Please delete the files below manually'
VIEWPAGEIN: 'View Page in:' VIEWPAGEIN: 'View Page in:'
ErrorPage: ErrorPage:
@ -323,9 +323,9 @@ en:
LINKCHANGENOTE: 'Changing this page''s link will also affect the links of all child pages.' LINKCHANGENOTE: 'Changing this page''s link will also affect the links of all child pages.'
MENUTITLE: 'Navigation label' MENUTITLE: 'Navigation label'
METADESC: 'Meta Description' METADESC: 'Meta Description'
METADESCHELP: 'Search engines use this content for displaying search results (although it will not influence their ranking).'
METAEXTRA: 'Custom Meta Tags' METAEXTRA: 'Custom Meta Tags'
METAEXTRAHELP: 'HTML tags for additional meta information. For example &lt;meta name="customName" content="your custom content here" /&gt;' METAKEYWORDS: 'Meta Keywords'
METATITLE: 'Meta Title'
MODIFIEDONDRAFTHELP: 'Page has unpublished changes' MODIFIEDONDRAFTHELP: 'Page has unpublished changes'
MODIFIEDONDRAFTSHORT: Modified MODIFIEDONDRAFTSHORT: Modified
MetadataToggle: Metadata MetadataToggle: Metadata
@ -387,8 +387,6 @@ en:
VIEWLAST: 'View last' VIEWLAST: 'View last'
VIEWNEXT: 'View next' VIEWNEXT: 'View next'
VIEWPREVIOUS: 'View previous' VIEWPREVIOUS: 'View previous'
TreeTools:
DisplayLabel: 'Display:'
ViewArchivedEmail.ss: ViewArchivedEmail.ss:
CANACCESS: 'You can access the archived site at this link:' CANACCESS: 'You can access the archived site at this link:'
HAVEASKED: 'You have asked to view the content of our site on' HAVEASKED: 'You have asked to view the content of our site on'

View File

@ -17,10 +17,18 @@ class SiteTreeMaintenanceTask extends Controller {
$urlSegment = $page->URLSegment; $urlSegment = $page->URLSegment;
$page->write(); $page->write();
if($urlSegment != $page->URLSegment) { if($urlSegment != $page->URLSegment) {
echo sprintf(_t('SiteTree.LINKSCHANGEDTO', " changed %s -> %s"), $urlSegment, $page->URLSegment); echo _t(
'SiteTree.LINKSCHANGEDTO',
" changed {url1} -> {url2}",
array('url1' => $urlSegment, 'url2' => $page->URLSegment)
);
} }
else { else {
echo sprintf(_t('SiteTree.LINKSALREADYUNIQUE', " %s is already unique"), $urlSegment); echo _t(
'SiteTree.LINKSALREADYUNIQUE',
" {url} is already unique",
array('url' => $urlSegment)
);
} }
die(); die();
} }