FIX namespaced _t() calls

This commit is contained in:
Franco Springveldt 2017-09-14 10:27:40 +12:00
parent 7c8866d280
commit e6cf037369
14 changed files with 61 additions and 61 deletions

View File

@ -90,7 +90,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
if (!$id) { if (!$id) {
$gridField->setCustomValidationMessage( $gridField->setCustomValidationMessage(
_t( _t(
'GridFieldAddByDBField.AddFail', __CLASS__ . '.AddFail',
'Unable to save {class} to the database.', 'Unable to save {class} to the database.',
'Unable to add the DataObject.', 'Unable to add the DataObject.',
array( array(
@ -103,7 +103,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
return Security::permissionFailure( return Security::permissionFailure(
Controller::curr(), Controller::curr(),
_t( _t(
'GridFieldAddByDBField.PermissionFail', __CLASS__ . '.PermissionFail',
'You don\'t have permission to create a {class}.', 'You don\'t have permission to create a {class}.',
'Unable to add the DataObject.', 'Unable to add the DataObject.',
array( array(
@ -186,7 +186,7 @@ class GridFieldAddByDBField implements GridField_ActionProvider, GridField_HTMLP
$gridField, $gridField,
'add', 'add',
_t( _t(
'GridFieldAddByDBField.Add', __CLASS__ . '.Add',
'Add {name}', 'Add {name}',
'Add button text', 'Add button text',
['name' => $obj->i18n_singular_name()] ['name' => $obj->i18n_singular_name()]

View File

@ -24,7 +24,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
$modifiedLabel = ''; $modifiedLabel = '';
if ($record->isModifiedOnStage) { if ($record->isModifiedOnStage) {
$modifiedLabel = '<span class="modified">' . _t('GridFieldBlogPostState.Modified') . '</span>'; $modifiedLabel = '<span class="modified">' . _t(__CLASS__ . '.Modified') . '</span>';
} }
if (!$record->isPublished()) { if (!$record->isPublished()) {
@ -34,7 +34,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
$lastEdited = $record->dbObject('LastEdited'); $lastEdited = $record->dbObject('LastEdited');
return _t( return _t(
'GridFieldBlogPostState.Draft', __CLASS__ . '.Draft',
'<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}', '<i class="btn-icon gridfield-icon btn-icon-pencil"></i> Saved as Draft on {date}',
'State for when a post is saved.', 'State for when a post is saved.',
array( array(
@ -50,7 +50,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
if (strtotime($record->PublishDate) > time()) { if (strtotime($record->PublishDate) > time()) {
return _t( return _t(
'GridFieldBlogPostState.Timer', __CLASS__ . '.Timer',
'<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}', '<i class="gridfield-icon blog-icon-timer"></i> Publish at {date}',
'State for when a post is published.', 'State for when a post is published.',
array( array(
@ -60,7 +60,7 @@ class GridFieldBlogPostState extends GridFieldSiteTreeState
} }
return _t( return _t(
'GridFieldBlogPostState.Published', __CLASS__ . '.Published',
'<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}', '<i class="btn-icon gridfield-icon btn-icon-accept"></i> Published on {date}',
'State for when a post is published.', 'State for when a post is published.',
array( array(

View File

@ -151,7 +151,7 @@ class Blog extends Page implements PermissionProvider
$categories = GridField::create( $categories = GridField::create(
'Categories', 'Categories',
_t('Blog.Categories', 'Categories'), _t(__CLASS__ . '.Categories', 'Categories'),
$this->Categories(), $this->Categories(),
GridFieldCategorisationConfig::create( GridFieldCategorisationConfig::create(
15, 15,
@ -164,7 +164,7 @@ class Blog extends Page implements PermissionProvider
$tags = GridField::create( $tags = GridField::create(
'Tags', 'Tags',
_t('Blog.Tags', 'Tags'), _t(__CLASS__ . '.Tags', 'Tags'),
$this->Tags(), $this->Tags(),
GridFieldCategorisationConfig::create( GridFieldCategorisationConfig::create(
15, 15,
@ -282,15 +282,15 @@ class Blog extends Page implements PermissionProvider
} }
if ($this->isEditor($member)) { if ($this->isEditor($member)) {
return _t('Blog.EDITOR', 'Editor'); return _t(__CLASS__ . '.EDITOR', 'Editor');
} }
if ($this->isWriter($member)) { if ($this->isWriter($member)) {
return _t('Blog.WRITER', 'Writer'); return _t(__CLASS__ . '.WRITER', 'Writer');
} }
if ($this->isContributor($member)) { if ($this->isContributor($member)) {
return _t('Blog.CONTRIBUTOR', 'Contributor'); return _t(__CLASS__ . '.CONTRIBUTOR', 'Contributor');
} }
return null; return null;
@ -349,7 +349,7 @@ class Blog extends Page implements PermissionProvider
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Settings', 'Root.Settings',
NumericField::create('PostsPerPage', _t('Blog.PostsPerPage', 'Posts Per Page')) NumericField::create('PostsPerPage', _t(__CLASS__ . '.PostsPerPage', 'Posts Per Page'))
); );
$members = $this->getCandidateUsers()->map()->toArray(); $members = $this->getCandidateUsers()->map()->toArray();
@ -586,7 +586,7 @@ class Blog extends Page implements PermissionProvider
*/ */
public function getLumberjackTitle() public function getLumberjackTitle()
{ {
return _t('Blog.LumberjackTitle', 'Blog Posts'); return _t(__CLASS__ . '.LumberjackTitle', 'Blog Posts');
} }
/** /**
@ -607,14 +607,14 @@ class Blog extends Page implements PermissionProvider
return array( return array(
Blog::MANAGE_USERS => array( Blog::MANAGE_USERS => array(
'name' => _t( 'name' => _t(
'Blog.PERMISSION_MANAGE_USERS_DESCRIPTION', __CLASS__ . '.PERMISSION_MANAGE_USERS_DESCRIPTION',
'Manage users for individual blogs' 'Manage users for individual blogs'
), ),
'help' => _t( 'help' => _t(
'Blog.PERMISSION_MANAGE_USERS_HELP', __CLASS__ . '.PERMISSION_MANAGE_USERS_HELP',
'Allow assignment of Editors, Writers, or Contributors to blogs' 'Allow assignment of Editors, Writers, or Contributors to blogs'
), ),
'category' => _t('Blog.PERMISSIONS_CATEGORY', 'Blog permissions'), 'category' => _t(__CLASS__ . '.PERMISSIONS_CATEGORY', 'Blog permissions'),
'sort' => 100 'sort' => 100
) )
); );

View File

@ -72,6 +72,6 @@ class BlogCategory extends DataObject implements CategorisationObject
*/ */
protected function getDuplicateError() protected function getDuplicateError()
{ {
return _t('BlogCategory.Duplicate', 'A blog category already exists with that name.'); return _t(__CLASS__ . '.Duplicate', 'A blog category already exists with that name.');
} }
} }

View File

@ -326,7 +326,7 @@ class BlogController extends PageController
if ($currentPage > 1) { if ($currentPage > 1) {
$items[] = _t( $items[] = _t(
'Blog.FILTERDESCRIPTION_PAGE', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_PAGE',
'Page {page}', 'Page {page}',
null, null,
array( array(
@ -337,7 +337,7 @@ class BlogController extends PageController
if ($author = $this->getCurrentProfile()) { if ($author = $this->getCurrentProfile()) {
$items[] = _t( $items[] = _t(
'Blog.FILTERDESCRIPTION_AUTHOR', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_AUTHOR',
'By {author}', 'By {author}',
null, null,
array( array(
@ -348,7 +348,7 @@ class BlogController extends PageController
if ($tag = $this->getCurrentTag()) { if ($tag = $this->getCurrentTag()) {
$items[] = _t( $items[] = _t(
'Blog.FILTERDESCRIPTION_TAG', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_TAG',
'Tagged with {tag}', 'Tagged with {tag}',
null, null,
array( array(
@ -359,7 +359,7 @@ class BlogController extends PageController
if ($category = $this->getCurrentCategory()) { if ($category = $this->getCurrentCategory()) {
$items[] = _t( $items[] = _t(
'Blog.FILTERDESCRIPTION_CATEGORY', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_CATEGORY',
'In category {category}', 'In category {category}',
null, null,
array( array(
@ -378,7 +378,7 @@ class BlogController extends PageController
} }
$items[] = _t( $items[] = _t(
'Blog.FILTERDESCRIPTION_DATE', 'SilverStripe\\Blog\\Model\\Blog.FILTERDESCRIPTION_DATE',
'In {date}', 'In {date}',
null, null,
array( array(

View File

@ -111,11 +111,11 @@ class BlogMemberExtension extends DataExtension
Requirements::css(BLOGGER_DIR . '/css/cms.css'); Requirements::css(BLOGGER_DIR . '/css/cms.css');
Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
$tab = Tab::create('BlogPosts', _t('BlogMemberExtension.TABBLOGPOSTS', 'Blog Posts')); $tab = Tab::create('BlogPosts', _t(__CLASS__ . '.TABBLOGPOSTS', 'Blog Posts'));
$gridField = GridField::create( $gridField = GridField::create(
'BlogPosts', 'BlogPosts',
_t('BlogMemberExtension.BLOGPOSTS', 'Blog Posts'), _t(__CLASS__ . '.BLOGPOSTS', 'Blog Posts'),
$this->owner->BlogPosts(), $this->owner->BlogPosts(),
GridFieldConfig_BlogPost::create() GridFieldConfig_BlogPost::create()
); );

View File

@ -35,12 +35,11 @@ trait BlogObject
*/ */
public function getCMSFields() public function getCMSFields()
{ {
$shortClass = ClassInfo::shortName(self::class);
$fields = TabSet::create( $fields = TabSet::create(
'Root', 'Root',
Tab::create( Tab::create(
'Main', 'Main',
TextField::create('Title', _t($shortClass . '.Title', 'Title')) TextField::create('Title', _t(__CLASS__ . '.Title', 'Title'))
) )
); );

View File

@ -169,7 +169,7 @@ class BlogPost extends Page
} }
if ($this->isAuthor($member)) { if ($this->isAuthor($member)) {
return _t('BlogPost.AUTHOR', 'Author'); return _t(__CLASS__ . '.AUTHOR', 'Author');
} }
$parent = $this->Parent(); $parent = $this->Parent();
@ -212,7 +212,7 @@ class BlogPost extends Page
Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
$this->beforeUpdateCMSFields(function ($fields) { $this->beforeUpdateCMSFields(function ($fields) {
$uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image')); $uploadField = UploadField::create('FeaturedImage', _t(__CLASS__ . '.FeaturedImage', 'Featured Image'));
$uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
/** /**
@ -223,13 +223,13 @@ class BlogPost extends Page
$summary = HtmlEditorField::create('Summary', false); $summary = HtmlEditorField::create('Summary', false);
$summary->setRows(5); $summary->setRows(5);
$summary->setDescription(_t( $summary->setDescription(_t(
'BlogPost.SUMMARY_DESCRIPTION', __CLASS__ . '.SUMMARY_DESCRIPTION',
'If no summary is specified the first 30 words will be used.' 'If no summary is specified the first 30 words will be used.'
)); ));
$summaryHolder = ToggleCompositeField::create( $summaryHolder = ToggleCompositeField::create(
'CustomSummary', 'CustomSummary',
_t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'), _t(__CLASS__ . '.CUSTOMSUMMARY', 'Add A Custom Summary'),
array( array(
$summary, $summary,
) )
@ -249,18 +249,18 @@ class BlogPost extends Page
$authorField = ListboxField::create( $authorField = ListboxField::create(
'Authors', 'Authors',
_t('BlogPost.Authors', 'Authors'), _t(__CLASS__ . '.Authors', 'Authors'),
$this->getCandidateAuthors()->map()->toArray() $this->getCandidateAuthors()->map()->toArray()
); );
$authorNames = TextField::create( $authorNames = TextField::create(
'AuthorNames', 'AuthorNames',
_t('BlogPost.AdditionalCredits', 'Additional Credits'), _t(__CLASS__ . '.AdditionalCredits', 'Additional Credits'),
null, null,
1024 1024
)->setDescription( )->setDescription(
_t( _t(
'BlogPost.AdditionalCredits_Description', __CLASS__ . '.AdditionalCredits_Description',
'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.' 'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.'
) )
); );
@ -270,12 +270,12 @@ class BlogPost extends Page
$authorNames = $authorNames->performDisabledTransformation(); $authorNames = $authorNames->performDisabledTransformation();
} }
$publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date')); $publishDate = DatetimeField::create('PublishDate', _t(__CLASS__ . '.PublishDate', 'Publish Date'));
if (!$this->PublishDate) { if (!$this->PublishDate) {
$publishDate->setDescription( $publishDate->setDescription(
_t( _t(
'BlogPost.PublishDate_Description', __CLASS__ . '.PublishDate_Description',
'Will be set to "now" if published without a value.' 'Will be set to "now" if published without a value.'
) )
); );
@ -299,7 +299,7 @@ class BlogPost extends Page
$urlSegment, $urlSegment,
TagField::create( TagField::create(
'Categories', 'Categories',
_t('BlogPost.Categories', 'Categories'), _t(__CLASS__ . '.Categories', 'Categories'),
$categories, $categories,
$this->Categories() $this->Categories()
) )
@ -307,7 +307,7 @@ class BlogPost extends Page
->setShouldLazyLoad(true), ->setShouldLazyLoad(true),
TagField::create( TagField::create(
'Tags', 'Tags',
_t('BlogPost.Tags', 'Tags'), _t(__CLASS__ . '.Tags', 'Tags'),
$tags, $tags,
$this->Tags() $this->Tags()
) )
@ -721,7 +721,7 @@ class BlogPost extends Page
{ {
$labels = parent::fieldLabels($includeRelations); $labels = parent::fieldLabels($includeRelations);
$labels['Title'] = _t('BlogPost.PageTitleLabel', 'Post Title'); $labels['Title'] = _t(__CLASS__ . '.PageTitleLabel', 'Post Title');
return $labels; return $labels;
} }

View File

@ -72,6 +72,6 @@ class BlogTag extends DataObject implements CategorisationObject
*/ */
protected function getDuplicateError() protected function getDuplicateError()
{ {
return _t('BlogTag.Duplicate', 'A blog tag already exists with that name.'); return _t(__CLASS__ . '.Duplicate', 'A blog tag already exists with that name.');
} }
} }

View File

@ -71,7 +71,7 @@ class BlogArchiveWidget extends Widget
$type = $archiveType->enumValues(); $type = $archiveType->enumValues();
foreach ($type as $k => $v) { foreach ($type as $k => $v) {
$type[$k] = _t('BlogArchiveWidget.' . ucfirst(strtolower($v)), $v); $type[$k] = _t(__CLASS__ .'.' . ucfirst(strtolower($v)), $v);
} }
/** /**
@ -80,11 +80,11 @@ class BlogArchiveWidget extends Widget
$fields->merge(array( $fields->merge(array(
DropdownField::create( DropdownField::create(
'BlogID', 'BlogID',
_t('BlogArchiveWidget.Blog', 'Blog'), _t(__CLASS__ . '.Blog', 'Blog'),
Blog::get()->map() Blog::get()->map()
), ),
DropdownField::create('ArchiveType', _t('BlogArchiveWidget.ArchiveType', 'ArchiveType'), $type), DropdownField::create('ArchiveType', _t(__CLASS__ . '.ArchiveType', 'ArchiveType'), $type),
NumericField::create('NumberToDisplay', _t('BlogArchiveWidget.NumberToDisplay', 'No. to Display')) NumericField::create('NumberToDisplay', _t(__CLASS__ . '.NumberToDisplay', 'No. to Display'))
)); ));
}); });

View File

@ -11,6 +11,7 @@ use SilverStripe\Core\Convert;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\NumericField; use SilverStripe\Forms\NumericField;
use SilverStripe\ORM\DataList;
use SilverStripe\Widgets\Model\Widget; use SilverStripe\Widgets\Model\Widget;
/** /**
@ -57,18 +58,18 @@ class BlogCategoriesWidget extends Widget
$this->beforeUpdateCMSFields(function (FieldList $fields) { $this->beforeUpdateCMSFields(function (FieldList $fields) {
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'BlogID', 'BlogID',
_t('BlogCategoriesWidget.Blog', 'Blog'), _t(__CLASS__ . '.Blog', 'Blog'),
Blog::get()->map() Blog::get()->map()
); );
$fields[] = NumericField::create( $fields[] = NumericField::create(
'Limit', 'Limit',
_t('BlogCategoriesWidget.Limit', 'Limit'), _t(__CLASS__ . '.Limit', 'Limit'),
0 0
) )
->setDescription( ->setDescription(
_t( _t(
'BlogCategoriesWidget.Limit_Description', __CLASS__ . '.Limit_Description',
'Limit the number of categories shown by this widget (set to 0 to show all categories).' 'Limit the number of categories shown by this widget (set to 0 to show all categories).'
) )
) )
@ -76,21 +77,21 @@ class BlogCategoriesWidget extends Widget
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Order', 'Order',
_t('BlogCategoriesWidget.Sort', 'Sort'), _t(__CLASS__ . '.Sort', 'Sort'),
array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated')
) )
->setDescription( ->setDescription(
_t('BlogCategoriesWidget.Sort_Description', 'Change the order of categories shown by this widget.') _t(__CLASS__ . '.Sort_Description', 'Change the order of categories shown by this widget.')
); );
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Direction', 'Direction',
_t('BlogCategoriesWidget.Direction', 'Direction'), _t(__CLASS__ . '.Direction', 'Direction'),
array('ASC' => 'Ascending', 'DESC' => 'Descending') array('ASC' => 'Ascending', 'DESC' => 'Descending')
) )
->setDescription( ->setDescription(
_t( _t(
'BlogCategoriesWidget.Direction_Description', __CLASS__ . '.Direction_Description',
'Change the direction of ordering of categories shown by this widget.' 'Change the direction of ordering of categories shown by this widget.'
) )
); );

View File

@ -57,8 +57,8 @@ class BlogRecentPostsWidget extends Widget
* @var FieldList $fields * @var FieldList $fields
*/ */
$fields->merge(array( $fields->merge(array(
DropdownField::create('BlogID', _t('BlogRecentPostsWidget.Blog', 'Blog'), Blog::get()->map()), DropdownField::create('BlogID', _t(__CLASS__ . '.Blog', 'Blog'), Blog::get()->map()),
NumericField::create('NumberOfPosts', _t('BlogRecentPostsWidget.NumberOfPosts', 'Number of Posts')) NumericField::create('NumberOfPosts', _t(__CLASS__ . '.NumberOfPosts', 'Number of Posts'))
)); ));
}); });

View File

@ -58,7 +58,7 @@ class BlogTagsCloudWidget extends Widget
$fields->push( $fields->push(
DropdownField::create( DropdownField::create(
'BlogID', 'BlogID',
_t('BlogTagsCloudWidget.Blog', 'Blog'), _t(__CLASS__ . '.Blog', 'Blog'),
Blog::get()->map() Blog::get()->map()
) )
); );

View File

@ -57,18 +57,18 @@ class BlogTagsWidget extends Widget
$this->beforeUpdateCMSFields(function (Fieldlist $fields) { $this->beforeUpdateCMSFields(function (Fieldlist $fields) {
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'BlogID', 'BlogID',
_t('BlogTagsWidget.Blog', 'Blog'), _t(__CLASS__ . '.Blog', 'Blog'),
Blog::get()->map() Blog::get()->map()
); );
$fields[] = NumericField::create( $fields[] = NumericField::create(
'Limit', 'Limit',
_t('BlogTagsWidget.Limit', 'Limit'), _t(__CLASS__ . '.Limit', 'Limit'),
0 0
) )
->setDescription( ->setDescription(
_t( _t(
'BlogTagsWidget.Limit_Description', __CLASS__ . '.Limit_Description',
'Limit the number of tags shown by this widget (set to 0 to show all tags).' 'Limit the number of tags shown by this widget (set to 0 to show all tags).'
) )
) )
@ -76,21 +76,21 @@ class BlogTagsWidget extends Widget
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Order', 'Order',
_t('BlogTagsWidget.Sort', 'Sort'), _t(__CLASS__ . '.Sort', 'Sort'),
array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated') array('Title' => 'Title', 'Created' => 'Created', 'LastEdited' => 'Updated')
) )
->setDescription( ->setDescription(
_t('BlogTagsWidget.Sort_Description', 'Change the order of tags shown by this widget.') _t(__CLASS__ . '.Sort_Description', 'Change the order of tags shown by this widget.')
); );
$fields[] = DropdownField::create( $fields[] = DropdownField::create(
'Direction', 'Direction',
_t('BlogTagsWidget.Direction', 'Direction'), _t(__CLASS__ . '.Direction', 'Direction'),
array('ASC' => 'Ascending', 'DESC' => 'Descending') array('ASC' => 'Ascending', 'DESC' => 'Descending')
) )
->setDescription( ->setDescription(
_t( _t(
'BlogTagsWidget.Direction_Description', __CLASS__ . '.Direction_Description',
'Change the direction of ordering of tags shown by this widget.' 'Change the direction of ordering of tags shown by this widget.'
) )
); );