Personal tools
You are here: Home Source News Software Internationalizing Plone News
Document Actions

Internationalizing Plone News

In a previous article, I introduced the problem with some of Plone's slots with I18N contents. My last posting provided a fix for portlet_events; now, I tackle the news.

This requires customization of two objects: portal_skins/plone_portlets/news_slot, and

portal_skins/plone_templates/news:

news_slot

<!-- customized for internationalization -->
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      i18n:domain="plone">
<body>
<!-- The news box -->
<div metal:define-macro="portlet"
     tal:define="brains python:request.get('news', here.portal_catalog.searchResults( portal_type='News Item'                                                                                     
, sort_on='Date'                                                                                
, sort_order='reverse'                                                                     
, review_state='published'));
              results python:[ 
        test(brain.getObject().getParentNode().portal_type == 'I18NLayer', brain.getObject().getParentNode(), brain.getObject() )
                    
             for brain in brains if brain.getObject()];
                resultsasSet python:[];
                temp python:[resultsasSet.append(i) for i in results if i not in resultsasSet];
                resultsasSet python: resultsasSet[:5]
		"
                 
     tal:condition="python:test(template.getId()!='news' and results, 1, 0)">
    <div class="portlet" id="portlet-news">
        <h5 i18n:translate="box_news">News</h5>
        <div class="portletBody">

            <tal:block tal:repeat="obj resultsasSet">

                <div tal:define="oddrow repeat/obj/odd"
                     tal:attributes="class python:test(oddrow, 'portletContent even', 'portletContent odd')">

                    <a href=""
                       tal:attributes="href python:obj.absolute_url();
                                       title obj/Description">
                        <tal:block replace="structure here/newsitem_icon.gif"/>
                        <span tal:replace="python:test(obj.Title(), obj.Title(), obj.getId())"> Extended Calendar Product </span>
                    </a>
                    <div class="portletDetails"
                         tal:content="python:here.toPortalTime(obj.Date())">July 7, 08:11</div>
                </div>
            </tal:block>
            <div class="portletContent odd">
                <a href=""
                   class="portletMore"
                   tal:attributes="href string:/news"
                   i18n:translate="box_morelink"
                   >
                    More...
                </a>
            </div>
        </div>
    </div>
</div>
</body>
</html>

news

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      lang="en"
      metal:use-macro="here/main_template/macros/master"
      i18n:domain="plone">
<head>
    <metal:block fill-slot="top_slot"
                 tal:define="dummy python:request.set('disable_border', 1)" />
    <tal:comment replace="nothing">
    Please note that this template will most likely be renamed to news_listing
    in the future, so if you reference this template or its macros from
    another template, make sure to change it when you upgrade.
    </tal:comment>
</head>
<body>
<div metal:fill-slot="main" id="content-news"
     tal:define="results python:container.portal_catalog(portal_type='News Item',sort_on='Date',sort_order='reverse',review_state='published');
                 results python:[test(r.getObject().getParentNode().portal_type == 'I18NLayer', r.getObject().getParentNode(), r.getObject()) for r in results if r.getObject()];
                 resultsasSet python:[];
                 temp python:[resultsasSet.append(i) for i in results if i not in resultsasSet];
                 Batch python:modules['Products.CMFPlone'].Batch;
                 b_start python:request.get('b_start',0);
                 portal_discussion nocall:here/portal_discussion;
                 isDiscussionAllowedFor nocall:portal_discussion/isDiscussionAllowedFor;
                 getDiscussionFor nocall:portal_discussion/getDiscussionFor;
                 home_url python: mtool.getHomeUrl;
                 localized_time python: modules['Products.CMFPlone.PloneUtilities'].localized_time;">

    <form name="searchresults" action="" method="post" tal:condition="resultsasSet"
               tal:define="batch python:Batch(resultsasSet, 15, int(b_start), orphan=1)" >
        <metal:block tal:repeat="result resultsasSet">
            <div class="newsItem"
                 metal:define-macro="listitem"
                 tal:define="resultObject result;
                             creator python:result.Creator();
                             resulturl python:result.absolute_url();">
                <h2>
                    <a href="/view" 
                       tal:attributes="href resulturl" 
                       tal:content="python:result.Title()">
                        News headline
                    </a>
                </h2>
                <div class="newsContent">
                    <p tal:content="structure python:result.Description()">
                        Description
                    </p>
                    <ul class="newsAbout">
 
                        <li>
                            <span tal:omit-tag="" i18n:translate="posted_by">Posted by</span>
    
                            <span class="link-user">
                                <a href=""
                                   tal:attributes="href python: home_url(creator)" 
                                   tal:content="creator">
                                    Author
                                </a>
                            </span>
                        </li>
                        <li>
                            <span tal:omit-tag="" i18n:translate="label_published">Published</span>:
                            <span tal:replace="python: localized_time(result.Date(), context=here)" />
                        </li>
                    </ul>
                     <ul class="newsFooter" tal:define="is_discussable python: isDiscussionAllowedFor(resultObject);">
                        <li>
                            <a href="/view" tal:attributes="href resulturl" i18n:translate="read_more">
                                Read More</a>
                        </li>
                        <tal:discussable condition="is_discussable">
                        <li tal:attributes="class python: test(has_replies, 'visualCommentAlign link-comment','visualCommentAlign');"
                            tal:define="talkback python: getDiscussionFor(resultObject);
                                        has_replies python: talkback.hasReplies(resultObject);">
                            <a href="" 
                               tal:define="reply_count python:talkback.replyCount(resultObject)"
                               tal:condition="reply_count"
                               tal:attributes="href string:${resulturl}#comments;">
                               (<span tal:replace="python: reply_count" />)</a>
                        </li>
                        </tal:discussable>
                    </ul>   
                </div>
            </div>
        </metal:block>
        <!-- Navigation -->
        <div metal:use-macro="here/batch_macros/macros/navigation" />
        </form>
    <p tal:condition="not: results" i18n:translate="no_new_news">
        No news has been posted.
    </p>
  </div>
</body>
</html>
Houston Tech Calendar

Events in the Houston area that have caught our attention ... or attendance ;)

« July 2010 »
Su Mo Tu We Th Fr Sa
123
45678910
11121314151617
18192021222324
25262728293031
 

Powered by Plone CMS, the Open Source Content Management System Hosted by WebFaction

This site conforms to the following standards: