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:51 +01:00
parent c054ab49a2
commit 661a4a2492
3 changed files with 24 additions and 9 deletions

View File

@ -85,8 +85,15 @@ class RequiredFields extends Validator {
}
if($formField && $error) {
$errorMessage = sprintf(_t('Form.FIELDISREQUIRED', '%s is required'),
strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"'));
$errorMessage = _t(
'Form.FIELDISREQUIRED',
'{name} is required',
array(
'name' => strip_tags(
'"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"'
)
)
);
if($msg = $formField->getCustomValidationMessage()) {
$errorMessage = $msg;

View File

@ -412,10 +412,16 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
// TODO Save this item into the given relationship
$message = sprintf(
_t('GridFieldDetailForm.Saved', 'Saved %s %s'),
$this->record->singular_name(),
'<a href="' . $this->Link('edit') . '">"' . htmlspecialchars($this->record->Title, ENT_QUOTES) . '"</a>'
$link = '<a href="' . $this->Link('edit') . '">"'
. htmlspecialchars($this->record->Title, ENT_QUOTES)
. '"</a>';
$message = _t(
'GridFieldDetailForm.Saved',
'Saved {name} {link}',
array(
'name' => $this->record->singular_name(),
'link' => $link
)
);
$form->sessionMessage($message, 'good');

View File

@ -1,6 +1,5 @@
en:
AssetAdmin:
ALLOWEDEXTS: 'Allowed extensions'
NEWFOLDER: NewFolder
AssetTableField:
CREATED: 'First uploaded'
@ -198,7 +197,7 @@ en:
TEXT2: 'password reset link'
TEXT3: for
Form:
FIELDISREQUIRED: '%s is required'
FIELDISREQUIRED: '{name} is required'
SubmitBtnLabel: Go
VALIDATIONCREDITNUMBER: 'Please ensure you have entered the {number} credit card number correctly'
VALIDATIONNOTUNIQUE: 'The value entered is not unique'
@ -237,7 +236,9 @@ en:
DeletePermissionsFailure: 'No delete permissions'
Deleted: 'Deleted %s %s'
Save: Save
Saved: 'Saved %s %s'
Saved: 'Saved {name} {link}'
GridFieldEditButton.ss:
EDIT: Edit
GridFieldItemEditView.ss:
'Go back': 'Go back'
Group:
@ -368,6 +369,7 @@ en:
NEWPASSWORD: 'New Password'
PASSWORD: Password
PLURALNAME: Members
PROFILESAVESUCCESS: 'Successfully saved.'
REMEMBERME: 'Remember me next time?'
SINGULARNAME: Member
SUBJECTPASSWORDCHANGED: 'Your password has been changed'