Skip to content

Translations do not work when run via cron #8412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fooman opened this issue Feb 3, 2017 · 6 comments
Closed

Translations do not work when run via cron #8412

fooman opened this issue Feb 3, 2017 · 6 comments
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@fooman
Copy link
Contributor

fooman commented Feb 3, 2017

Preconditions

  1. Magento 2.1.3 (and earlier)

Steps to reproduce

  1. Install a language pack, for example composer require imaginaerum/magento2-language-fr-fr
  2. Create a new Store View "French"
  3. Select fr_FR locale for this Store View
  4. Change Stores > Configuration > Sales > Sales Email > General Settings > Asynchronous sending to Enabled
  5. Place a new order from the French store
  6. Ensure Magento's cronjob bin/magento cron:run is executing and that the order confirmation email has been sent

Expected result

  1. Order Confirmation Email is sent in French

Actual result

screen shot 2017-02-04 at 11 30 48

Please note that the locale for email is correctly emulated as can be seen by formatting of the currency amounts.

@thomvanderboon
Copy link

Did you deploy the french language pack?

php bin/magento setup:static-content:deploy en_US fr_FR
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush

Thom

@fooman
Copy link
Contributor Author

fooman commented Feb 4, 2017

Yes the email was correctly translated if sending asynchronously is disabled.

@reindert-vetter
Copy link
Contributor

reindert-vetter commented Feb 5, 2017

I have the same problem. Temporarily resolved with the following solution:
#3805 (comment)

    /**
     * @var \Magento\Framework\App\AreaList
     */
    private $areaList;

    public function __construct(\Magento\Framework\App\AreaList $areaList) {
            $this->areaList = $areaList;
    }

    private function execute() {
            $areaObject = $this->areaList->getArea(\Magento\Framework\App\Area::AREA_ADMINHTML);
            $areaObject->load(\Magento\Framework\App\Area::PART_TRANSLATE);

            var_dump(__('Registered'));
    }

@fooman
Copy link
Contributor Author

fooman commented Feb 5, 2017

@reindert-vetter thanks for confirming. I have suggested a fix in this PR #8413 which is the same solution just on a higher level (cron not only the template). If you could confirm that my changes here https://github.com/magento/magento2/pull/8413/files also work for you that be great.

mmansoor-magento pushed a commit that referenced this issue Feb 11, 2017
…8413

 - Merge Pull Request #8413 from fooman/magento2:fix-8412-cron-not-translated
michalhosna pushed a commit to manGoweb/magento2 that referenced this issue Aug 30, 2017
@freezable
Copy link

Hallo, I have "solve" this issue with using \Magento\Store\Model\App\Emulation::startEnvironmentEmulation() function before sending and stopping after.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jan 9, 2018
@mrtuvn
Copy link
Contributor

mrtuvn commented Jul 5, 2023

Hi just reported in 2.4.5-p3 version

Magento removed part translate from abstract template email
Any ideas why of this changes
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Email/Model/AbstractTemplate.php#L515

controller part translate init
https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/App/FrontController.php#L189

Also i got experience crontab mail render seem not correct get phase translate (english still be used)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

6 participants