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

Translatable object name in success message #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions code/SingleObjectAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ public function doSave($data, $form)
}
}

$link = '"' . $object->singular_name() . '"';
$link = '"' . $object->i18n_singular_name() . '"';
$message = _t(
'GridFieldDetailForm.Saved',
'Saved {name} {link}',
array(
'name' => $object->singular_name(),
'link' => $link
'name' => $object->i18n_singular_name(),
'link' => ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this been removed? If we're removing it can we remove the {link} field and delete the array key?

Copy link
Author

@faloude faloude Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This _t() function refers to GridFieldDetailForm.Saved in the framework lang file framework/lang/nl.yml which has this value:

Saved: '{name} {link} opgeslagen'

The translation file is expecting a {link} so completely removing 'link' => $link from the array would leave a meaningless DataObject saved {link} in the success-message, whereas an empty value for 'link' doesn't leave any marks. If we would remove {link} from the array we would need to remove it from each and every framework lang file which isn't desired obviously.

)
);

Expand Down Expand Up @@ -228,7 +228,7 @@ private function publish($data, $form)

if ($object) {
$object->doPublish();
$form->sessionMessage($object->singular_name() . ' has been saved.', 'good');
$form->sessionMessage($object->i18n_singular_name() . ' has been saved.', 'good');
} else {
$form->sessionMessage('Something failed, please refresh your browser.', 'bad');
}
Expand Down