# User locale in command

**URL:** <https://discourse.cakephp.org/t/user-locale-in-command/5211>\
**Category:** Need Help\
**Tags:** translation, i18n\
**Created:** [November 6, 2018, 10:46am UTC](https://discourse.cakephp.org/t/user-locale-in-command/5211 "2018-11-06T10:46:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![okelet](https://avatars.discourse-cdn.com/v4/letter/o/919ad9/32.png) [@okelet](https://discourse.cakephp.org/u/okelet)\
**Post date:** [November 6, 2018, 10:46am UTC](https://discourse.cakephp.org/t/user-locale-in-command/5211/1 "2018-11-06T10:46:58Z")

</div>

I have created a command that generates some reports periodically and sends them to users. I want to send the mails, from the command, in the user locale (is a user column in DB). How can I set the user locale in a command, to make `__("My string")` be translated?

---

<div class="post-metadata">

**Author:** ![okelet](https://avatars.discourse-cdn.com/v4/letter/o/919ad9/32.png) [@okelet](https://discourse.cakephp.org/u/okelet)\
**Post date:** [November 6, 2018, 11:53am UTC](https://discourse.cakephp.org/t/user-locale-in-command/5211/2 "2018-11-06T11:53:54Z")

</div>

OK… sorry. right simple, even in commands (I thought it would be a special case):

```auto
<?php
namespace App\Command;

use Cake\Console\Arguments;
use Cake\Console\Command;
use Cake\Console\ConsoleIo;
use Cake\I18n\I18n;

class HelloCommand extends Command
{

    public function execute(Arguments $args, ConsoleIo $io)
    {

        I18n::setLocale('es_ES');
        echo __("Actions") . "\n";

    }

}

```

Output:

```auto
$ bin/cake hello
Acciones

```
