# Translations in Cron job

**URL:** <https://discuss.tryton.org/t/translations-in-cron-job/7373>\
**Category:** Developer\
**Tags:** ir\
**Created:** [June 10, 2024, 12:37pm UTC](https://discuss.tryton.org/t/translations-in-cron-job/7373 "2024-06-10T12:37:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)\
**Post date:** [June 10, 2024, 12:37pm UTC](https://discuss.tryton.org/t/translations-in-cron-job/7373/1 "2024-06-10T12:37:28Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [June 10, 2024, 1:11pm UTC](https://discuss.tryton.org/t/translations-in-cron-job/7373/2 "2024-06-10T13:11:54Z")

</div>

> [@Xavi](#):
>
> but not if its cron, even if the cron user have ‘es’ set as language.

We do not use any cron user since [Simplify cron (32265209fd9e) · Commits · Tryton / Tryton · GitLab](https://code.tryton.org/tryton/commit/32265209fd9e) and even at that time we did not use the language of this user.

> [@Xavi](#):
>
> I’ve also tried to change the language value in the database section of config file

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.

> [@Xavi](#):
>
> but I don’t think I should write on the code the language I want

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.

---

<div class="post-metadata">

**Author:** ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)\
**Post date:** [June 11, 2024, 5:14am UTC](https://discuss.tryton.org/t/translations-in-cron-job/7373/3 "2024-06-11T05:14:04Z")

</div>

Got it, thank you for your help.

---

<div class="post-metadata">

**Author:** ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)\
**Post date:** [June 11, 2024, 5:14pm UTC](https://discuss.tryton.org/t/translations-in-cron-job/7373/4 "2024-06-11T17:14:24Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
