Most of these issues can be solved by understanding Pyramid's i18n docs.
A couple things. First, the Chameleon environment needs to have a localizer configured. Pyramid does this for you when you use the default Chameleon setup by calling render('templates/my_email.pt', opts, request=request)
. If you are using Chameleon's API directly, I do not think the localizer will be found. Also, you'll need a locale negotiator to determine what locale the localizer should be using. There is a default negotiator, but if you are doing this outside of a request, the locale for the user may not be properly configured.
Anyway, my recommendation is to stick to using Pyramid's renderers instead of using Chameleon directly because you lose a lot of the useful configuration Pyramid does for you in this area.
If you cannot use one of Pyramid's renderers for some reason, the i18n docs I linked show how the underlying system works. You need a localizer
. Pyramid uses gettext. You then create a TranslationString
instance and invoke result = localizer.translate(ts)
. This is all happening behind the scenes using the default renderers.