Open dbitouze opened 5 years ago
Currently the code to send the email is
translated_template = translate(
SEND_USERNAME_TEMPLATE,
context=self.request,
)
mail_text = translated_template.format(
email=userinfo['email'],
portal_url=portal.absolute_url(),
fullname=userinfo['title'],
login=userinfo['login'],
email_from_name=registry['plone.email_from_name'],
encoded_mail_sender=self.encoded_mail_sender(),
)
So the message is translated and then those variables are replaced with .format
.
This works because those variables doesn't need to be translated but it's not the proper way to internalize messages.
The message should indeed use the ${var}
syntax and the python code should be:
translated_template = translate(
SEND_USERNAME_TEMPLATE,
context=self.request,
mapping={
'email': userinfo['email'],
'portal_url': portal.absolute_url(),
'fullname': userinfo['title'],
'login': userinfo['login'],
'email_from_name': registry['plone.email_from_name'],
'encoded_mail_sender': self.encoded_mail_sender(),
})
Somebody can propose a PR for Products.CMFPlone and another for plone.app.locales to update all translations to use dollar variables to avoid fuzzy messages. I'm pretty sure nobody will do the changes... so I close the issue, feel free to reopen if somebody want to work on it.
Why closing this issue before it is fixed? If somebody wants to work on it, at least (s)he will need to be aware of it :)
Sure if you want, I reopen. I changed the title.
In the lines:
https://github.com/plone/Products.CMFPlone/blob/cfa56163281a965c46eebea1ab25951b786fc0cc/Products/CMFPlone/browser/login/login_help.py#L28-L44
aren't missing
$
in front of all the{...}
variables, e.g. shouldn'tYour username for {portal_url}
beYour username for ${portal_url}
?