From 6229b8960dcce8d15e32313ebd75d624d321932b Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Tue, 18 Dec 2007 01:41:51 +0000 Subject: [PATCH] v.golev: #1982 - Blog module i18n patch --- code/ArchiveWidget.php | 2 +- code/BlogEntry.php | 14 ++++---- code/BlogHolder.php | 54 ++++++++++++++++--------------- code/BlogManagementWidget.php | 6 ++-- code/RSSWidget.php | 6 ++-- code/TagCloudWidget.php | 4 +-- lang/_manifest_exclude | 0 lang/en_US.php | 47 +++++++++++++++++++++++++++ lang/ru_RU.php | 47 +++++++++++++++++++++++++++ templates/BlogManagementWidget.ss | 4 +-- templates/Includes/BlogSummary.ss | 4 +-- templates/Layout/BlogEntry.ss | 8 ++--- templates/Layout/BlogHolder.ss | 6 ++-- 13 files changed, 149 insertions(+), 53 deletions(-) create mode 100644 lang/_manifest_exclude create mode 100644 lang/en_US.php create mode 100644 lang/ru_RU.php diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php index a04a788..4c77715 100644 --- a/code/ArchiveWidget.php +++ b/code/ArchiveWidget.php @@ -27,7 +27,7 @@ class ArchiveWidget extends Widget { function getCMSFields() { return new FieldSet( - new OptionsetField("DisplayMode","Display by",array("month"=>"month","year"=>"year")) + new OptionsetField("DisplayMode",_t('ArchiveWidget.DispBY', "Display by"),array("month"=>_t('ArchiveWidget.MONTH',"month"),"year"=>_t('ArchiveWidget.YEAR', "year"))) ); } diff --git a/code/BlogEntry.php b/code/BlogEntry.php index 9f59529..2ae8b5c 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -3,7 +3,7 @@ /** * @package blog */ - + /** * An individual blog entry page to show a blog entry in full */ @@ -64,19 +64,19 @@ class BlogEntry extends Page { if(!self::$allow_wysiwyg_editing) { $fields->removeFieldFromTab("Root.Content.Main","Content"); - $fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", "Content", 20)); + $fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20)); } - $fields->addFieldToTab("Root.Content.Main", new CalendarDateField("Date", "Date"),"Content"); - $fields->addFieldToTab("Root.Content.Main", new TextField("Author", "Author", $firstName),"Content"); + $fields->addFieldToTab("Root.Content.Main", new CalendarDateField("Date", _t("BlogEntry.DT", "Date")),"Content"); + $fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content"); if(!self::$allow_wysiwyg_editing) { $fields->addFieldToTab("Root.Content.Main", new LiteralField("BBCodeHelper", "
" . - "BBCode help" . + "" . _t("BlogEntry.BBH", "BBCode help") / "" . "
")); } - $fields->addFieldToTab("Root.Content.Main", new TextField("Tags", "Tags (comma sep.)"),"Content"); + $fields->addFieldToTab("Root.Content.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content"); return $fields; } @@ -134,7 +134,7 @@ class BlogEntry extends Page { } /** - * Link for editing this blog entry + * Link for editing this blog entry */ function EditURL(){ return $this->getParent()->Link('post')."/".$this->ID."/"; diff --git a/code/BlogHolder.php b/code/BlogHolder.php index c428f6c..914a537 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -3,11 +3,11 @@ /** * @package blog */ - + /** * Blog holder to display summarised blog entries */ - + class BlogHolder extends Page { static $icon = "blog/images/blogholder"; @@ -43,7 +43,7 @@ class BlogHolder extends Page { */ function getNewsletters() { return DataObject::get('NewsletterType'); - } + } /** * The DataObject of blog entries @@ -68,12 +68,11 @@ class BlogHolder extends Page { } else { $year = Director::urlParam('Action'); $month = Director::urlParam('ID'); - + if(is_numeric($month) && is_numeric($month)){ $dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-$month-1' AND '$year-$month-31'"; - } - else if(isset($year)){ - $dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-1-1' AND '$year-12-31'"; + } else if(isset($year)){ + $dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-1-1' AND '$year-12-31'"; } } } @@ -85,6 +84,9 @@ class BlogHolder extends Page { * Only display the blog entries that have the specified tag */ function Tag() { + if(Director::urlParam('Action') == 'tag') { + return Director::urlParam('ID'); + } return isset($_GET['tag']) ? $_GET['tag'] : false; } @@ -110,19 +112,19 @@ class BlogHolder extends Page { new HiddenField("ParentID", "ParentID", $this->ID), new HiddenField("ID","ID"), new HiddenField("Date","Date"), - new TextField("Title","Subject"), - new TextField("Author","Author",$membername), + new TextField("Title",_t('BlogHolder.SJ', "Subject")), + new TextField("Author",_t('BlogEntry.AU'),$membername), new CompositeField( - new LiteralField("BBCodeHelper","BBCode help
" ), - new TextareaField("Content", "Content",20), + new LiteralField("BBCodeHelper",""._t("BlogEntry.BBH")."
" ), + new TextareaField("Content", _t("BlogEntry.CN"),20), new LiteralField("BBCodeTags","") ), new TextField("Tags","Tags"), - new LiteralField("Tagsnote"," ") + new LiteralField("Tagsnote"," ") ); - $submitAction = new FormAction('postblog', 'Post blog entry'); + $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry')); $actions = new FieldSet($submitAction); $validator = new RequiredFields('Title','Content'); @@ -136,7 +138,7 @@ class BlogHolder extends Page { return $form; } - + /** * Check if url has "/post" */ @@ -150,7 +152,7 @@ class BlogHolder extends Page { function postURL(){ return $this->Link('post'); } - + /** * Create default blog setup */ @@ -185,11 +187,11 @@ class BlogHolder extends Page { $widgetarea->write(); $blog = new BlogEntry(); - $blog->Title = "SilverStripe blog module successfully installed"; + $blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed"); $blog->URLSegment = 'sample-blog-entry'; $blog->setDate(date("Y-m-d H:i:s",time())); - $blog->Tags = "silverstripe, blog"; - $blog->Content = "Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in [url=admin]the CMS[/url]."; + $blog->Tags = _t('BlogHolder.SUCTAGS',"silverstripe, blog"); + $blog->Content = _t('BlogHolder.SUCCONTENT',"Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in [url=admin]the CMS[/url]."); $blog->Status = "Published"; $blog->ParentID = $blogholder->ID; $blog->write(); @@ -202,16 +204,17 @@ class BlogHolder extends Page { class BlogHolder_Controller extends Page_Controller { function init() { - parent::init(); + parent::init(); + // This will create a tag point to the RSS feed - RSSFeed::linkToFeed($this->Link() . "rss", "RSS feed of this blog"); + RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of this blog")); Requirements::themedCSS("blog"); Requirements::themedCSS("bbcodehelp"); } - + /** - * Get the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/ + * Gets the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/ */ function showarchive() { $month = addslashes($this->urlParams['ID']); @@ -236,7 +239,7 @@ class BlogHolder_Controller extends Page_Controller { } /** - * Get the rss fee for this blog holder's entries + * Get the rss feed for this blog holder's entries */ function rss() { global $project; @@ -257,7 +260,7 @@ class BlogHolder_Controller extends Page_Controller { function post(){ if(!Permission::check('ADMIN')){ Security::permissionFailure($this, - "Posting blogs is an administrator task. Please log in."); + _t('BlogHolder.HAVENTPERM',"Posting blogs is an administrator task. Please log in.")); } return array(); } @@ -270,7 +273,6 @@ class BlogHolder_Controller extends Page_Controller { return parent::defaultAction($action); } - } /** diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php index a680699..0fbb41e 100644 --- a/code/BlogManagementWidget.php +++ b/code/BlogManagementWidget.php @@ -10,11 +10,11 @@ class BlogManagementWidget extends Widget { function CommentText() { $unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value(); if($unmoderatedcount == 1) { - return "You have 1 unmoderated comment"; + return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment"); } else if($unmoderatedcount > 1) { - return "You have $unmoderatedcount unmoderated comments"; + return sprintf(_t("BlogManagementWidget.UNMM", "You have %i unmoderated comments"), $unmoderatedcount); } else { - return "Comment administration"; + return _t("BlogManagementWidget.COMADM", "Comment administration"); } } diff --git a/code/RSSWidget.php b/code/RSSWidget.php index 79bb2e8..b17e97d 100644 --- a/code/RSSWidget.php +++ b/code/RSSWidget.php @@ -17,9 +17,9 @@ class RSSWidget extends Widget { function getCMSFields() { return new FieldSet( - new TextField("CustomTitle","Custom title for the feed"), - new TextField("RssUrl", "URL of RSS Feed"), - new NumericField("NumberToShow", "Number of Items to show") + new TextField("CustomTitle", _t('RSSWidget.CT', "Custom title for the feed")), + new TextField("RssUrl", _t('RSSWidget.URL', "URL of RSS Feed")), + new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show")) ); } diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php index 7e8b08b..ebacb13 100644 --- a/code/TagCloudWidget.php +++ b/code/TagCloudWidget.php @@ -30,8 +30,8 @@ class TagCloudWidget extends Widget { function getCMSFields() { return new FieldSet( - new TextField("Limit", "Limit number of tags"), - new OptionsetField("Sortby","Sort by",array("alphabet"=>"alphabet","frequency"=>"frequency")) + new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")), + new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency"))) ); } diff --git a/lang/_manifest_exclude b/lang/_manifest_exclude new file mode 100644 index 0000000..e69de29 diff --git a/lang/en_US.php b/lang/en_US.php new file mode 100644 index 0000000..929ecd6 --- /dev/null +++ b/lang/en_US.php @@ -0,0 +1,47 @@ + diff --git a/lang/ru_RU.php b/lang/ru_RU.php new file mode 100644 index 0000000..bd15a69 --- /dev/null +++ b/lang/ru_RU.php @@ -0,0 +1,47 @@ + diff --git a/templates/BlogManagementWidget.ss b/templates/BlogManagementWidget.ss index fdd8682..c2e6a6a 100644 --- a/templates/BlogManagementWidget.ss +++ b/templates/BlogManagementWidget.ss @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/templates/Includes/BlogSummary.ss b/templates/Includes/BlogSummary.ss index 5d91392..df2e045 100644 --- a/templates/Includes/BlogSummary.ss +++ b/templates/Includes/BlogSummary.ss @@ -1,6 +1,6 @@
-

$MenuTitle

-

Posted by $Author.XML on $Date.Long | $Comments.Count Comments

+

$MenuTitle

+

<% _t('BlogEntry.ss.POSTEDBY') %> $Author.XML <% _t('BlogEntry.ss.POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('BlogEntry.ss.COMMENTS', 'Comments') %>

<% if Tags %>

Tags: diff --git a/templates/Layout/BlogEntry.ss b/templates/Layout/BlogEntry.ss index ecaff0e..260958f 100644 --- a/templates/Layout/BlogEntry.ss +++ b/templates/Layout/BlogEntry.ss @@ -4,19 +4,19 @@

$Title

-

Posted by $Author.XML on $Date.Long | $Comments.Count Comments

+

<% _t('POSTEDBY', 'Posted by') %> $Author.XML <% _t('POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('COMMENTS', 'Comments') %>

<% if Tags %>

- Tags: + <% _t('TAGS', 'Tags:') %> <% control Tags %> - <% if Last %><% else %>,<% end_if %> + <% if Last %><% else %>,<% end_if %> <% end_control %>

<% end_if %>

$ParsedContent


- <% if CurrentMember %>

Edit this post | Unpublish this post

<% end_if %> + <% if CurrentMember %>

<% _t('EDITTHIS', 'Edit this post') %> | <% _t('UNPUBLISHTHIS', 'Unpublish this post') %>

<% end_if %> $PageComments diff --git a/templates/Layout/BlogHolder.ss b/templates/Layout/BlogHolder.ss index 79f6276..d0d3eec 100644 --- a/templates/Layout/BlogHolder.ss +++ b/templates/Layout/BlogHolder.ss @@ -5,7 +5,7 @@ <% include BreadCrumbs %> <% if Tag %> -

Viewing entries tagged with '$Tag'

+

<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'

<% end_if %> <% if BlogEntries %> @@ -13,9 +13,9 @@ <% include BlogSummary %> <% end_control %> <% else %> -

There are no blog entries

+

<% _t('NOENTRIES', 'There are no blog entries') %>

<% end_if %> <% include BlogPagination %> -
\ No newline at end of file +