Skip to content

Commit

Permalink
Added more improvements about i18n support #3
Browse files Browse the repository at this point in the history
  • Loading branch information
macagua committed Jan 4, 2020
1 parent efba1b6 commit b901b8f
Show file tree
Hide file tree
Showing 35 changed files with 342 additions and 308 deletions.
1 change: 1 addition & 0 deletions Products/listen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import content
import permissions
import Products.listen.i18n

# Add builtin mailboxer skin
from Products.MailBoxer.config import SKINS_DIR as MB_SKINS_DIR
Expand Down
9 changes: 6 additions & 3 deletions Products/listen/browser/archive_date_messages.pt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
tal:condition="view/canPost"
tal:attributes="href string:${here_url}/new_topic;"
i18n:translate="label_forum_new_topic_button">
Post New Topic
Post New Topic
</a>

<ul id="message-list-actions">
Expand All @@ -59,8 +59,11 @@
<ul id="message-list">
<li tal:repeat="message messages">
<a href="."
tal:attributes="href message/url;"
><strong tal:content="structure message/brief_subject"><tal:comment replace="nothing">Re: Subj</tal:comment></strong></a> &mdash;
tal:attributes="href message/url;">
<strong tal:content="structure message/brief_subject">
<tal:comment replace="nothing">Re: Subj</tal:comment>
</strong>
</a> &mdash;
<a href="."
tal:omit-tag="not:message/from_id"
tal:attributes="href string:${portal_url}/author/${message/from_id}"
Expand Down
19 changes: 9 additions & 10 deletions Products/listen/browser/archive_date_view.pt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<metal:archive-view use-macro="here/@@forum_view/macros/archive">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"
i18n:domain="plone">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="listen">
<body>
<div metal:fill-slot="body">
<div metal:define-macro="body"
tal:define="dates view/getAvailableDates;
template_id string:date_view;"
i18n:domain="listen">
template_id string:date_view;">

<div metal:define-slot="extra_info" tal:replace="nothing">
</div>

<div class="row"
metal:define-slot="extra_top" tal:replace="nothing">
<div i18n:translate="" class="label">Extra top</div>
<div class="label" i18n:translate="">Extra top</div>
</div>

<h1 i18n:translate="" tal:content="view/Title" class="documentFirstHeading">
<h1 tal:content="view/Title" class="documentFirstHeading">
Title or Id
</h1>

Expand All @@ -33,8 +33,8 @@
Description
</p>

<ul id="message-list-actions">
<li>
<ul id="message-list-actions">
<li>
<a id="switch_view" href="forum_view"
i18n:translate="">Forum view</a>
</li>
Expand All @@ -48,7 +48,6 @@
<ul tal:condition="year/children">
<li tal:repeat="month year/children">
<a href="."
i18n:translate=""
tal:attributes="href month/url"
tal:content="month/title">November</a>
</li>
Expand Down
25 changes: 11 additions & 14 deletions Products/listen/browser/archive_forum_view.pt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<metal:archive-view define-macro="archive">
<tal:comment condition="nothing">
We set the template_id to ensure correct highlighting, and we use the
actions defined for the parent mailing list
We set the template_id to ensure correct highlighting, and we use the
actions defined for the parent mailing list
</tal:comment>
<tal:defines define="dummy python:options.setdefault('template_id', 'archive');
dummy python:options.setdefault('actions', here.portal_actions.listFilteredActionsFor(view.getMailingList()))" />
Expand All @@ -11,7 +11,7 @@
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
metal:use-macro="here/main_template/macros/master"
i18n:domain="plone">
i18n:domain="listen">

<metal:fillbase fill-slot="base">
<metal:baseslot define-slot="base">
Expand Down Expand Up @@ -43,8 +43,7 @@
Document actions (print, sendto etc)
</div>

<div metal:define-slot="body"
i18n:domain="listen">
<div metal:define-slot="body">
<tal:threads define="batch view/getTopics;
threads python:batch.topic_list;">

Expand All @@ -53,10 +52,10 @@

<div class="row"
metal:define-slot="extra_top" tal:replace="nothing">
<div i18n:translate="" class="label">Extra top</div>
<div class="label" i18n:translate="">Extra top</div>
</div>

<h1 i18n:translate="" tal:content="view/Title" class="documentFirstHeading">
<h1 tal:content="view/Title" class="documentFirstHeading">
Title or Id
</h1>

Expand All @@ -75,7 +74,8 @@
<table cellpadding="20">
<tr>
<td>
<a i18n:translate="" tal:attributes="href string:${here_url}/date_view;" href="#">Switch to date view</a>
<a tal:attributes="href string:${here_url}/date_view;"
href="#" i18n:translate="">Switch to date view</a>
</td>
<td>
<a href="#"
Expand Down Expand Up @@ -115,8 +115,7 @@

<td>
<a href="#"
i18n:translate=""
tal:content="structure item/brief_subject"
tal:content="structure item/brief_subject"
tal:attributes="href item/url">
Subject</a>
</td>
Expand All @@ -128,10 +127,8 @@
<span tal:replace="structure item/mail_from">[email protected]</span>
</a>
</td>
<td tal:content="item/responses"
>10</td>
<td tal:content="item/last_post" i18n:translate=""
>12/1/2005 3:54 pm</td>
<td tal:content="item/responses">10</td>
<td tal:content="item/last_post">12/1/2005 3:54 pm</td>
</tr>
</tal:items>
</tbody>
Expand Down
23 changes: 13 additions & 10 deletions Products/listen/browser/archive_thread_messages.pt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<metal:archive-view use-macro="here/@@forum_view/macros/archive">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"
i18n:domain="plone">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="listen">
<body>
<div metal:fill-slot="body">
<div metal:define-macro="body"
tal:define="thread view/getThreadedMessageStructure;
template_id string:by_date;"
i18n:domain="listen">
template_id string:by_date;">

<div metal:define-slot="extra_info" tal:replace="nothing">
</div>

<div class="row"
metal:define-slot="extra_top" tal:replace="nothing">
<div i18n:translate="" class="label">Extra top</div>
<div class="label" i18n:translate="">Extra top</div>
</div>

<h1 i18n:translate="" tal:content="view/Title" class="documentFirstHeading">
<h1 tal:content="view/Title" class="documentFirstHeading">
Title or Id
</h1>

Expand All @@ -38,7 +38,7 @@
tal:condition="view/canPost"
tal:attributes="href string:${here_url}/new_topic;"
i18n:translate="label_forum_new_topic_button">
Post New Topic
Post New Topic
</a>

<ul id="message-list-actions">
Expand All @@ -57,8 +57,11 @@
<ul id="message-list">
<li tal:repeat="message thread">
<a href="."
tal:attributes="href message/url;"
><strong tal:content="structure message/brief_subject"><tal:comment replace="nothing">Re: Subj</tal:comment></strong></a> &mdash;
tal:attributes="href message/url;">
<strong tal:content="structure message/brief_subject">
<tal:comment replace="nothing">Re: Subj</tal:comment>
</strong>
</a> &mdash;
<a href="."
tal:omit-tag="not:message/from_id"
tal:attributes="href string:${portal_url}/author/${message/from_id}"
Expand Down
9 changes: 4 additions & 5 deletions Products/listen/browser/forum_message_view.pt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tal:ml define="ml view/getMailingList">
<metal:archive-view use-macro="ml/archive/@@forum_view/macros/archive">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"
xml:lang="en" lang="en"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
Expand All @@ -16,7 +16,7 @@
<div metal:define-macro="body"
tal:define="messages view/getMessageBodies;">

<h1 i18n:translate="" tal:content="structure messages/subject" class="documentFirstHeading">
<h1 tal:content="structure messages/subject" class="documentFirstHeading">
Title or Id
</h1>
<a id="to_threaded" href="."
Expand Down Expand Up @@ -57,7 +57,7 @@
i18n:translate="option_forum_recent_first">Recent First</option>
</select>
<input name="forum-update"
i18n:attributes="value"
i18n:attributes="value"
value="update"
type="submit"/>
</form>
Expand All @@ -66,8 +66,7 @@
tal:define="thread view/getReplyStructure;
local_thread thread/children;
use_id_anchors python:True">
<dt i18n:translate="label_threaded_replies">
Thread Outline:</dt>
<dt i18n:translate="label_threaded_replies">Thread Outline:</dt>
<dd>
<div metal:use-macro="here/message_macros/macros/thread" />
</dd>
Expand Down
17 changes: 12 additions & 5 deletions Products/listen/browser/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ def __call__(self):
key = key[len(UNDO_SUBMIT):]
msg_count = self.undo_import(key)
if msg_count:
txt = (_(u"Removed %s message%s from the list archive.")
% (msg_count, self._plural(msg_count)))
txt = (_(u'import_export_removed_message_status_msg',
u'Removed ${msg_count} message${msg_plural} from the list archive.',
mapping={'msg_count':msg_count,
'msg_plural':self._plural(msg_count)}))
plone_utils.addPortalMessage(txt, type='info')
self.request.response.redirect(self.nextURL())
return
Expand All @@ -82,8 +84,11 @@ def __call__(self):
self.filename = file.filename
self.save_import_history()
msg_count = len(self.msgids)
psm_text = (_(u'Imported %s message%s from \'%s\'')
% (msg_count, self._plural(msg_count), file.filename))
psm_text = (_(u'import_export_imported_message_status_msg',
u'Imported ${msg_count} message${msg_plural} from \'${filename}\'',
mapping={'msg_count':msg_count,
'msg_plural':self._plural(msg_count),
'filename':file.filename}))
psm_type = 'info'
else:
psm_text = _(u"No file selected. Please select an mbox file before importing.")
Expand All @@ -108,7 +113,9 @@ def __call__(self):
subscriber_importer.import_subscribers(emails)
n_emails = len(emails)
if n_emails != 1:
psm_text = _(u'%s email addresses imported') % n_emails
psm_text = _(u'psm_email_addresses_imported_msg',
u'${num_emails} email addresses imported',
mapping={'num_emails':n_emails})
else:
psm_text = _(u'1 email address imported')
psm_type = 'info'
Expand Down
2 changes: 1 addition & 1 deletion Products/listen/browser/listwidget/widget.pt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="listenwidget" id="test">
i18n:domain="listen" id="test">

<script type="text/javascript" src="listoperations.js"
tal:attributes="src python: view.resource_url()">
Expand Down
3 changes: 2 additions & 1 deletion Products/listen/browser/lookup_view.pt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<h1 i18n:translate="">Registered Mailing Lists</h1>

<table id="mailing-lists"
summary="A table of registered list addresses and the paths to the corresponding lists" i18n:attributes="summary summary_table_mailing_listsr;">
summary="A table of registered list addresses and the paths to the corresponding lists"
i18n:attributes="summary summary_table_mailing_listsr;">
<thead>
<tr>
<th i18n:translate="">List Address</th>
Expand Down
19 changes: 12 additions & 7 deletions Products/listen/browser/mail_archive_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from Products.Five import BrowserView

from Products.listen.i18n import _
from Products.listen.interfaces import ISearchableArchive
from Products.listen.interfaces import IMembershipList
from Products.listen.interfaces import IMailingList
Expand All @@ -29,7 +30,6 @@

from Products.listen.lib.common import construct_simple_encoded_message

from Products.listen.i18n import _
from zope.i18nmessageid import Message

class ArchiveBaseView(BrowserView):
Expand Down Expand Up @@ -180,7 +180,7 @@ def __call__(self):
# Make sure that the current user is allowed to post:
if not self.canPost():
raise Unauthorized, \
"You do not have permission to respond to this message."
_(u"You do not have permission to respond to this message.")
# Save the referring URL, either from the template form, or the
# HTTP_REFERER, otherwise just use the message url.
referring_url = (self.request.get('referring_url', None) or
Expand All @@ -190,8 +190,9 @@ def __call__(self):
submitted = self.request.get('submit', None)
cancelled = self.request.get('cancel', None)
if cancelled:
portal_status_msg=_(u"Post Cancelled")
return self.request.response.redirect(self.referring_url+
'?portal_status_message=Post%20Cancelled')
'?portal_status_message=%s' % (portal_status_msg))
if submitted:
self.errors = {}
body = self.request.get('body', None)
Expand All @@ -208,17 +209,21 @@ def __call__(self):
self.request.set('Mail', message)
result = ml.processMail(self.request)
if result == POST_ALLOWED:
portal_status_msg=_(u"Post Sent")
return self.request.response.redirect(self.referring_url+
'?portal_status_message=Post%20Sent')
'?portal_status_message=%s' % (portal_status_msg))
elif result == POST_DEFERRED:
portal_status_msg=_(u"Post Pending Moderation")
return self.request.response.redirect(self.referring_url+
'?portal_status_message=Post%20Pending%20Moderation')
'?portal_status_message=%s' % (portal_status_msg))
elif result == POST_DENIED:
portal_status_msg=_(u"Post Rejected: You already have a post pending moderation.")
return self.request.response.redirect(self.referring_url+
'?portal_status_message=Post%20Rejected:%20You%20already%20have%20a%20post%20pending%20moderation.')
'?portal_status_message=%s' % (portal_status_msg))
else:
portal_status_msg=_(u"Post Error")
return self.request.response.redirect(self.referring_url+
'?portal_status_message=Post%20Error')
'?portal_status_message=%s' % (portal_status_msg))



Expand Down
Loading

0 comments on commit b901b8f

Please sign in to comment.