From 519fe25da1c8859385c0728a6d9aa18f06f3e006 Mon Sep 17 00:00:00 2001 From: "marcio.barrientos" Date: Tue, 16 Jan 2018 11:17:41 -0600 Subject: [PATCH] Make Categorization and PostOptions localizable Allow to make localizable Blog Categorization tab and BlogPost Options tab --- lang/en.yml | 7 +++++++ src/Admin/GridFieldCategorisationConfig.php | 4 ++-- src/Admin/GridFieldMergeAction.php | 7 ++++--- src/Model/Blog.php | 4 +++- src/Model/BlogPost.php | 3 +++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lang/en.yml b/lang/en.yml index 2747605d8..051441c3f 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -46,6 +46,7 @@ en: UsersEditorsFieldDescription: "An editor has control over specific Blogs, and all posts included within it. \n Short of being able to assign other editors to a blog, they are able to handle most changes to\n their assigned blog.

\n Editors have these permissions:
\n
\n Update or publish any BlogPost in their Blog
\n Update or publish their Blog
\n Assign/unassign writers to their Blog
\n Assign/unassign contributors to their Blog
\n Assign/unassign any member as an author of a particular BlogPost" UsersWritersFieldDescription: "A writer has full control over creating, editing and publishing BlogPosts they have authored\n or have been assigned to. Writers are unable to edit BlogPosts to which they are not assigned.\n

\n Writers have these permissions:
\n
\n Update or publish any BlogPost they have authored or have been assigned to
\n Assign/unassign any member as an author of a particular BlogPost they have authored or have been \n assigned to" WRITER: Writer + Categorisation: 'Categorisation' SilverStripe\Blog\Model\BlogCategory: Duplicate: 'A blog category already exists with that name.' PLURALNAME: 'Blog Categories' @@ -74,6 +75,7 @@ en: SINGULARNAME: 'Blog Post' SUMMARY_DESCRIPTION: 'If no summary is specified the first 30 words will be used.' Tags: Tags + PostOptions: 'Post Options' SilverStripe\Blog\Model\BlogTag: Duplicate: 'A blog tag already exists with that name.' PLURALNAME: 'Blog Tags' @@ -131,3 +133,8 @@ en: SINGULARNAME: 'Blog Tags Widget' Sort: Sort Sort_Description: 'Change the order of tags shown by this widget.' + SilverStripe\Blog\Admin\GridFieldMergeAction: + MovePostsTo: 'Move posts to' + SilverStripe\Blog\Admin\GridFieldCategorisationConfig: + Title: Title + Posts: Posts diff --git a/src/Admin/GridFieldCategorisationConfig.php b/src/Admin/GridFieldCategorisationConfig.php index 15a2019db..2e22a15fd 100644 --- a/src/Admin/GridFieldCategorisationConfig.php +++ b/src/Admin/GridFieldCategorisationConfig.php @@ -58,8 +58,8 @@ protected function changeColumnOrder() $columns->setDisplayFields( [ - 'Title' => 'Title', - 'BlogPostsCount' => 'Posts', + 'Title' => _t(__CLASS__ . '.Title', 'Title'), + 'BlogPostsCount' => _t(__CLASS__ . '.Posts', 'Posts'), 'MergeAction' => 'MergeAction', 'Actions' => 'Actions' ] diff --git a/src/Admin/GridFieldMergeAction.php b/src/Admin/GridFieldMergeAction.php index 272f8d0bb..d1666a6db 100644 --- a/src/Admin/GridFieldMergeAction.php +++ b/src/Admin/GridFieldMergeAction.php @@ -102,9 +102,10 @@ public function getColumnContent($gridField, $record, $columnName) ]); $action->addExtraClass('btn btn-primary btn-sm blog-merge-action'); + $MovePostsTo = _t(__CLASS__ . '.MovePostsTo', 'Move posts to'); + $MergeActionReveal = '' . $MovePostsTo . ''; - return $dropdown->Field() . $action->Field() . - 'Move posts to'; + return $dropdown->Field() . $action->Field() . $MergeActionReveal; } return null; @@ -123,7 +124,7 @@ public function getColumnAttributes($gridField, $record, $columnName) */ public function getColumnMetadata($gridField, $columnName) { - return ['title' => 'Move posts to']; + return ['title' => _t(__CLASS__ . '.MovePostsTo', 'Move posts to')]; } /** diff --git a/src/Model/Blog.php b/src/Model/Blog.php index 6276dbf49..a3135e716 100644 --- a/src/Model/Blog.php +++ b/src/Model/Blog.php @@ -177,7 +177,9 @@ public function getCMSFields() ] ); - $fields->findOrMakeTab('Root.Categorisation')->addExtraClass('blog-cms-categorisation'); + $fields->fieldByName('Root.Categorisation') + ->addExtraClass('blog-cms-categorisation') + ->setTitle(_t(__CLASS__ . '.Categorisation', 'Categorisation')); }); return parent::getCMSFields(); diff --git a/src/Model/BlogPost.php b/src/Model/BlogPost.php index 505b6df1e..14ea9faf0 100644 --- a/src/Model/BlogPost.php +++ b/src/Model/BlogPost.php @@ -324,6 +324,9 @@ public function getCMSFields() $fields->fieldByName('Root')->setTemplate('TabSet_holder'); + $fields->fieldByName('Root.PostOptions') + ->setTitle(_t(__CLASS__ . '.PostOptions', 'Post Options')); + return $fields; }