Hi,
I have a cron job which sends an email, which is originally written in english, and I would like to translate it to other languages, (mainly spanish), it is only getting translated if its a normal user who runs the action, but not if its cron, even if the cron user have ‘es’ set as language.
I’ve been able to do it by using:
with Transaction().set_context(language='es'):
before sending the email, but I don’t think I should write on the code the language I want if the user have a field for it.
I’ve also tried to change the language value in the database section of config file but it looks like its not working, and Im not sure if this parameter is really what im looking for, am I missing something with this case?
tryton 6.0
Thanks.
This is stored in the database and can no more be changed once the database has been setup. But it is actually the default language that the cron task will be using.
Indeed this is what you must do.
Usually for such task we set the language for the receipts.
Indeed you can use trytond.report.get_email so it creates for you the email message with the content from the HTML report translated for each language with the proper Content-Language parameters.