From cf31a3d4e6b3d81160155bb4a5b0c5b9dbab06d4 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 12 Dec 2007 22:57:29 +0000 Subject: [PATCH] rhalff: #1580 - i18n for comments system git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@46723 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CommentAdmin.php | 24 ++++++++++----------- code/CommentTableField.php | 6 +++--- code/sitefeatures/PageComment.php | 2 +- code/sitefeatures/PageCommentInterface.php | 22 +++++++++---------- lang/en_US.php | 24 +++++++++++++++++++++ templates/Includes/CommentAdmin_SiteTree.ss | 10 ++++----- templates/Includes/CommentAdmin_left.ss | 4 ++-- templates/Includes/CommentTableField.ss | 12 +++++------ templates/PageCommentInterface.ss | 2 +- 9 files changed, 64 insertions(+), 42 deletions(-) diff --git a/code/CommentAdmin.php b/code/CommentAdmin.php index 54535a47..7103f196 100644 --- a/code/CommentAdmin.php +++ b/code/CommentAdmin.php @@ -36,22 +36,22 @@ class CommentAdmin extends LeftAndMain { if($section == 'approved') { $filter = 'IsSpam=0 AND NeedsModeration=0'; - $title = "

Approved Comments

"; + $title = "

". _t('CommentAdmin.APPROVEDCOMMENTS', 'Approved Comments')."

"; } else if($section == 'unmoderated') { $filter = 'NeedsModeration=1'; - $title = "

Comments Awaiting Moderation

"; + $title = "

"._t('CommentAdmin.COMMENTSAWAITINGMODERATION', 'Comments Awaiting Moderation')."

"; } else { $filter = 'IsSpam=1'; - $title = "

Spam

"; + $title = "

"._t('CommentAdmin.SPAM', 'Spam')."

"; } $filter .= ' AND ParentID>0'; $tableFields = array( - "Name" => "Author", - "Comment" => "Comment", - "PageTitle" => "Page", - "Created" => "Date Posted" + "Name" => _t('CommentAdmin.AUTHOR', 'Author'), + "Comment" => _t('CommentAdmin.COMMENT', 'Comment'), + "PageTitle" => _t('CommentAdmin.PAGE', 'Page'), + "Created" => _t('CommentAdmin.DATEPOSTED', 'Date Posted') ); $popupFields = new FieldSet( @@ -76,21 +76,21 @@ class CommentAdmin extends LeftAndMain { $actions = new FieldSet(); if($section == 'unmoderated') { - $actions->push(new FormAction('acceptmarked', 'Accept')); + $actions->push(new FormAction('acceptmarked', _t('CommentAdmin.ACCEPT', 'Accept'))); } if($section == 'approved' || $section == 'unmoderated') { - $actions->push(new FormAction('spammarked', 'Mark as spam')); + $actions->push(new FormAction('spammarked', _t('CommentAdmin.SPAMMARKED', 'Mark as spam'))); } if($section == 'spam') { - $actions->push(new FormAction('hammarked', 'Mark as not spam')); + $actions->push(new FormAction('hammarked', _t('CommentAdmin.MARKASNOTSPAM', 'Mark as not spam'))); } - $actions->push(new FormAction('deletemarked', 'Delete')); + $actions->push(new FormAction('deletemarked', _t('CommentAdmin.DELETE', 'Delete'))); if($section == 'spam') { - $actions->push(new FormAction('deleteall', 'Delete All')); + $actions->push(new FormAction('deleteall', _t('CommentAdmin.DELETEALL', 'Delete All'))); } $form = new Form($this, "EditForm", $fields, $actions); diff --git a/code/CommentTableField.php b/code/CommentTableField.php index b51b93f8..7db4db20 100644 --- a/code/CommentTableField.php +++ b/code/CommentTableField.php @@ -133,12 +133,12 @@ class CommentTableField extends ComplexTableField { function SearchForm() { $searchFields = new FieldGroup( - new TextField('CommentSearch', 'Search'), + new TextField('CommentSearch', _t('CommentTableField.SEARCH', 'Search')), new HiddenField("ctf[ID]",'',$this->mode), new HiddenField('CommentFieldName','',$this->name) ); - $actionFields = new LiteralField('CommentFilterButton',''); + $actionFields = new LiteralField('CommentFilterButton',''); $fieldContainer = new FieldGroup( $searchFields, @@ -176,4 +176,4 @@ class CommentTableField_Item extends ComplexTableField_Item { } } -?> \ No newline at end of file +?> diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index 47e83556..8da5dbcf 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -206,4 +206,4 @@ class PageComment extends DataObject { } -?> \ No newline at end of file +?> diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index a6d339bf..2769afb0 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -33,17 +33,16 @@ class PageCommentInterface extends ViewableData { $fields = new FieldSet( new HiddenField("ParentID", "ParentID", $this->page->ID), - new TextField("Name", "Your name") - ); + new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name'))); if(MathSpamProtection::isEnabled()){ - $fields->push(new TextField("Math","Spam protection question: ".MathSpamProtection::getMathQuestion())); + $fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion()))); } - $fields->push(new TextareaField("Comment", "Comments")); + $fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments"))); $form = new PageCommentInterface_Form($this->controller, $this->methodName . ".PostCommentForm",$fields, new FieldSet( - new FormAction("postcomment", "Post") + new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post')) )); $form->loadDataFrom(array( @@ -98,10 +97,9 @@ class PageCommentInterface_Form extends Form { $comment->setField("IsSpam", true); $comment->write(); } - echo "Spam detected!!

"; - echo "If you believe this was in error, please email "; - echo ereg_replace("@", " _(at)_", Email::getAdminEmail()); - echo ".

The message you posted was:

"; + echo ""._t('PageCommentInterface_Form.SPAMDETECTED', 'Spam detected!!') . "

"; + printf("If you believe this was in error, please email %s.", ereg_replace("@", " _(at)_", Email::getAdminEmail())); + echo "

"._t('PageCommentInterface_Form.MSGYOUPOSTED', 'The message you posted was:'). "

"; echo $data['Comment']; return; @@ -131,7 +129,7 @@ class PageCommentInterface_Form extends Form { if(Director::is_ajax()) { if($comment->NeedsModeration){ - echo "Your comment has been submitted and is now awating moderation."; + echo _t('PageCommentInterface_Form.AWAITINGMODERATION', "Your comment has been submitted and is now awating moderation."); } else{ echo $comment->renderWith('PageCommentInterface_singlecomment'); } @@ -148,9 +146,9 @@ class PageCommentInterface_Controller extends ContentController { function newspamquestion() { if(Director::is_ajax()) { - echo Convert::raw2xml("Spam protection question: ".MathSpamProtection::getMathQuestion()); + echo Convert::raw2xml(sprintf(_t('PageCommentInterface_Controller.SPAMQUESTION', "Spam protection question: %s"),MathSpamProtection::getMathQuestion())); } } } -?> \ No newline at end of file +?> diff --git a/lang/en_US.php b/lang/en_US.php index b02b1441..77793208 100755 --- a/lang/en_US.php +++ b/lang/en_US.php @@ -137,6 +137,20 @@ $lang['en_US']['CMSMain']['VISITRESTORE'] = array( PR_LOW, 'restorepage/(ID) should not be translated (is an URL)' ); +$lang['en_US']['CommentAdmin']['APPROVEDCOMMENTS'] = 'Approved Comments'; +$lang['en_US']['CommentAdmin']['COMMENTSAWAITINGMODERATION'] = 'Comments Awaiting Moderation'; +$lang['en_US']['CommentAdmin']['SPAM'] = 'Spam'; +$lang['en_US']['CommentAdmin']['AUTHOR'] = 'Author'; +$lang['en_US']['CommentAdmin']['COMMENT'] = 'Comment'; +$lang['en_US']['CommentAdmin']['PAGE'] = 'Page'; +$lang['en_US']['CommentAdmin']['DATEPOSTED'] = 'Date Posted'; +$lang['en_US']['CommentAdmin']['ACCEPT'] = 'Accept'; +$lang['en_US']['CommentAdmin']['SPAMMARKED'] = 'Mark as spam'; +$lang['en_US']['CommentAdmin']['MARKASNOTSPAM'] = 'Mark as not spam'; +$lang['en_US']['CommentAdmin']['DELETE'] = 'Delete'; +$lang['en_US']['CommentAdmin']['DELETEALL'] = 'Delete All'; +$lang['en_US']['CommentTableField']['SEARCH'] = 'Search'; +$lang['en_US']['CommentTableField']['FILTER'] = 'Filter'; $lang['en_US']['LeftAndMain']['PERMDEFAULT'] = 'Please choose an authentication method and enter your credentials to access the CMS.'; $lang['en_US']['LeftAndMain']['PERMALREADY'] = 'I\'m sorry, but you can\'t access that part of the CMS. If you want to log in as someone else, do so below'; $lang['en_US']['LeftAndMain']['PERMAGAIN'] = 'You have been logged out of the CMS. If you would like to log in again, enter a username and password below.'; @@ -244,6 +258,11 @@ $lang['en_US']['CMSMain_versions.ss']['NOTPUB'] = 'Not published'; $lang['en_US']['CommentList.ss']['NOCOM'] = 'There are no comments on this page.'; $lang['en_US']['CommentList.ss']['CREATEDW'] = 'Comments are created whenever one of the \'workflow actions\' are undertaken - Publish, Reject, Submit.'; +$lang['en_US']['CommentTableField.ss']['APPROVECOMMENT'] = 'Approve this comment'; +$lang['en_US']['CommentTableField.ss']['MARKASSPAM'] = 'Mark this comment as spam' ; +$lang['en_US']['CommentTableField.ss']['MARKNOSPAM'] = 'Mark this comment as not spam'; +$lang['en_US']['CommentTableField.ss']['DELETEROW'] = 'Delete this row'; +$lang['en_US']['CommentTableField.ss']['NOITEMSFOUND'] = 'No items found'; $lang['en_US']['ImageEditor.ss']['UNTITLED'] = 'Untitled Document'; $lang['en_US']['ImageEditor.ss']['SAVE'] = 'save image'; $lang['en_US']['ImageEditor.ss']['UNDO'] = 'undo'; @@ -328,6 +347,10 @@ $lang['en_US']['CMSMain_right.ss']['CHOOSEPAGE'] = 'Please choose a page from th $lang['en_US']['CMSRight.ss']['ECONTENT'] = 'Edit Content'; $lang['en_US']['CMSRight.ss']['WELCOMETO'] = 'Welcome to'; $lang['en_US']['CMSRight.ss']['CHOOSEPAGE'] = 'Please choose a page from the left.'; +$lang['en_US']['CommentAdmin_left.ss']['COMMENTS'] = 'Comments'; +$lang['en_US']['CommentAdmin_left.ss']['APPROVED'] = 'Approved'; +$lang['en_US']['CommentAdmin_left.ss']['AWAITMODERATION'] = 'Awaiting Moderation'; +$lang['en_US']['CommentAdmin_left.ss']['SPAM'] = 'Spam'; $lang['en_US']['GenericDataAdmin_left.ss']['ADDLISTING'] = 'Add Listing'; $lang['en_US']['GenericDataAdmin_left.ss']['SEARCHLISTINGS'] = 'Search Listings'; $lang['en_US']['GenericDataAdmin_left.ss']['SEARCHRESULTS'] = 'Search Results'; @@ -454,6 +477,7 @@ $lang['en_US']['PageCommentInterface.ss']['COMMENTS'] = 'Comments'; $lang['en_US']['PageCommentInterface.ss']['PREV'] = 'previous'; $lang['en_US']['PageCommentInterface.ss']['NEXT'] = 'next'; $lang['en_US']['PageCommentInterface.ss']['NOCOMMENTSYET'] = 'No one has commented on this page yet.'; +$lang['en_US']['PageCommentInterface.ss']['RSSFEEDCOMMENTS'] = 'RSS feed for comments on this page'; $lang['en_US']['PageCommentInterface_singlecomment.ss']['PBY'] = 'Posted by'; $lang['en_US']['PageCommentInterface_singlecomment.ss']['ISSPAM'] = 'this comment is spam'; $lang['en_US']['PageCommentInterface_singlecomment.ss']['ISNTSPAM'] = 'this comment is not spam'; diff --git a/templates/Includes/CommentAdmin_SiteTree.ss b/templates/Includes/CommentAdmin_SiteTree.ss index c0bdb55f..66ff19fc 100644 --- a/templates/Includes/CommentAdmin_SiteTree.ss +++ b/templates/Includes/CommentAdmin_SiteTree.ss @@ -1,15 +1,15 @@ \ No newline at end of file + diff --git a/templates/Includes/CommentAdmin_left.ss b/templates/Includes/CommentAdmin_left.ss index 46168f67..bfed4ed5 100644 --- a/templates/Includes/CommentAdmin_left.ss +++ b/templates/Includes/CommentAdmin_left.ss @@ -1,7 +1,7 @@ -

Comments

+

<% _t('COMMENTS', 'Comments') %>

<% include CommentAdmin_SiteTree %>
-
\ No newline at end of file + diff --git a/templates/Includes/CommentTableField.ss b/templates/Includes/CommentTableField.ss index f1d3f1a9..5733f4bc 100644 --- a/templates/Includes/CommentTableField.ss +++ b/templates/Includes/CommentTableField.ss @@ -47,23 +47,23 @@ edit <% end_if %> <% if HasApproveButton %> - approve + approve <% end_if %> <% if HasSpamButton %> - spam + spam <% end_if %> <% if HasHamButton %> - ham + ham <% end_if %> <% if Can(delete) %> - delete + delete <% end_if %> <% end_control %> <% else %> <% if Markable %> <% end_if %> - No items found + <% _t('NOITEMSFOUND', 'No items found') %> <% if Can(edit) %> <% end_if %> <% if HasApproveButton %> <% end_if %> <% if HasSpamButton %> <% end_if %> @@ -73,4 +73,4 @@ <% end_if %> - \ No newline at end of file + diff --git a/templates/PageCommentInterface.ss b/templates/PageCommentInterface.ss index ad655258..4b86569c 100755 --- a/templates/PageCommentInterface.ss +++ b/templates/PageCommentInterface.ss @@ -42,6 +42,6 @@

<% _t('NOCOMMENTSYET','No one has commented on this page yet.') %>

<% end_if %> -

RSS feed for comments on this page

+

<% _t('RSSFEEDCOMMENTS', 'RSS feed for comments on this page') %>