Skip to content

Commit 796bbd8

Browse files
authored
Merge pull request #298 from plone/erral-translation-fixes-main
Pass request as context parameter in the translate function (main branch)
2 parents 194d669 + 57b4c3a commit 796bbd8

5 files changed

Lines changed: 15 additions & 6 deletions

File tree

.meta.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# See the inline comments on how to expand/tweak this configuration file
44
[meta]
55
template = "default"
6-
commit-id = "2.2.1"
6+
commit-id = "2.3.2"
77

88
[pyproject]
99
dependencies_ignores = "['Products.LinguaPlone.interfaces.ITranslatable', 'collective.akismet', 'collective.z3cform.norobots', 'plone.formwidget.captcha', 'plone.formwidget.recaptcha', 'plone.formwidget.hcaptcha', 'plone.contentrules', 'plone.app.contentrules', 'plone.restapi', 'plone.stringinterp', 'plone.app.collection']"

news/+meta.internal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Update configuration files.
2+
[plone devs]

news/+translatecontext.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix translation of comment byline. @erral

src/plone/app/discussion/comment.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from zope.component import queryUtility
3636
from zope.component.factory import Factory
3737
from zope.event import notify
38+
from zope.globalrequest import getRequest
3839
from zope.i18n import translate
3940
from zope.i18nmessageid import Message
4041
from zope.interface import implementer
@@ -206,6 +207,7 @@ def Title(self):
206207
default="Anonymous",
207208
),
208209
),
210+
context=getRequest(),
209211
)
210212
else:
211213
author_name = self.author_name
@@ -220,8 +222,10 @@ def Title(self):
220222
"author_name": safe_text(author_name),
221223
"content": safe_text(content.Title()),
222224
},
223-
)
225+
),
226+
context=getRequest(),
224227
)
228+
225229
return title
226230

227231
def Creator(self):
@@ -381,7 +385,7 @@ def notify_user(obj, event):
381385
if not emails:
382386
return
383387

384-
subject = translate(_("A comment has been posted."), context=obj.REQUEST)
388+
subject = translate(_("A comment has been posted."), context=getRequest())
385389
message = translate(
386390
Message(
387391
MAIL_NOTIFICATION_MESSAGE,
@@ -391,7 +395,7 @@ def notify_user(obj, event):
391395
"text": obj.text,
392396
},
393397
),
394-
context=obj.REQUEST,
398+
context=getRequest(),
395399
)
396400
for email in emails:
397401
# Send email
@@ -449,7 +453,7 @@ def notify_moderator(obj, event):
449453
content_object = aq_parent(conversation)
450454

451455
# Compose email
452-
subject = translate(_("A comment has been posted."), context=obj.REQUEST)
456+
subject = translate(_("A comment has been posted."), context=getRequest())
453457
message = translate(
454458
Message(
455459
MAIL_NOTIFICATION_MESSAGE_MODERATOR,
@@ -465,10 +469,11 @@ def notify_moderator(obj, event):
465469
default="Anonymous",
466470
),
467471
),
472+
context=getRequest(),
468473
),
469474
},
470475
),
471-
context=obj.REQUEST,
476+
context=getRequest(),
472477
)
473478

474479
# Send email

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ description = check if the package defines all its dependencies
6262
skip_install = true
6363
deps =
6464
build
65+
setuptools<82.0.0
6566
z3c.dependencychecker==2.14.3
6667
commands =
6768
python -m build --sdist

0 commit comments

Comments
 (0)