magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.

Home Page:http://www.magento.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[2.2.0-RC2.2] Static content deploy with multiple locales: js-translation.json files are the same

hostep opened this issue · comments

Preconditions

  1. PHP 7.0.22

Steps to reproduce

  1. Install Magento 2.2.0-rc22 using composer
  2. Add 2 language packs using composer: composer require honl/magento2-nl-nl imaginaerum/magento2-language-fr-fr
  3. Create 2 different storeviews in the backend and set the Locale configuration to Dutch (Netherlands) and French (France) for those 2 storeviews
  4. Run php bin/magento setup:static-content:deploy -f -t Magento/luma nl_NL && php bin/magento setup:static-content:deploy -f -t Magento/luma fr_FR
  5. Run diff -rwq pub/static/frontend/Magento/luma/nl_NL/ pub/static/frontend/Magento/luma/fr_FR/
  6. Results: Files pub/static/frontend/Magento/luma/nl_NL/js-translation.json and pub/static/frontend/Magento/luma/fr_FR/js-translation.json differ => Good
  7. Remove all generated static files: rm -R pub/static/* var/view_preprocessed/*
  8. Run php bin/magento setup:static-content:deploy -f -t Magento/luma nl_NL fr_FR
  9. Run diff -rwq pub/static/frontend/Magento/luma/nl_NL/ pub/static/frontend/Magento/luma/fr_FR/
  10. Results: ... nothing, all files are equal => Not good

Expected result

  1. When generating static content using multiple locales in one go, the generated js-translation.json files should be different

Actual result

  1. When generating static content using multiple locales in one go, the generated js-translation.json files are the same
    This has as result that all javascript translations are in the wrong locale on the frontend.

Discussion

This is the same issue like I reported on #7862 for Magento 2.1.3, but this was supposed to be fixed by MAGETWO-62660, which is included in Magento 2.2.0-RC2.2, but looks like that didn't really help, or something else might broke it yet again ...

commented

Thanks for reporting - internal issue is MAGETWO-72301

@hostep, thank you for your report.
We've created internal ticket(s) MAGETWO-72301 to track progress on the issue.

Will be fixed in 2.2.1

Hello.
This is also an issue in 2.1.x. We have a 2.1.7. install and it's messing up big time. We have 6 locales in play. Not pretty.
So our deployment process to staging/live calls "bin/magento deploy:mode:set production".
At some point it calls a function deployStaticContent(...) in module-deploy/Model/Filesystem.php
You'll notice in here the line of code:
$cmd = $this->functionCallPath . 'setup:static-content:deploy '
. implode(' ', $this->getUsedLocales());

So you can see it's appending all the locales to the end of the :deploy. What we've had to do as a workaround is override this class and introduce a foreach performing a setup:static-content:deploy on every locale in the $this->getUsedLocales() array.
It's not pretty but it works. I haven't tested this on 2.2.x sorry.
Hope this helps.
Have a nice day.
Tadhg

@tadhgbowe: you can find a better workaround in: #7862, that's the issue for tracking this problem in 2.1.x

Internal ticket to track issue progress: MAGETWO-82752

Will be fixed in 2.2.1

nope - this is not fixed in 2.2.1

Still an issue in 2.2.1

I've been searching for several hours now (well, it's magento, what else would you expect) and finally came up with a solution.

deployment before:
php bin/magento setup:static-content:deploy de_DE en_US cs_CZ

This resulted in 3 equal js-translation.json files, where en_US and cs_CZ also contained the labels of the first translation de_DE

If you do separate deployment calls for each language it works as expected.

php bin/magento setup:static-content:deploy de_DE
php bin/magento setup:static-content:deploy en_US
php bin/magento setup:static-content:deploy cs_CZ

I also made a small shell script which simplifies this process, in case anyone is interested.

deploy.sh

#!/bin/bash

rm -rf pub/static/frontend/
rm -rf pub/static/adminhtml/
rm -rf var/view_processed/

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

still not fixed in 2.2.2

@Blueblazer172 it does seem to be working with v2.2.2 for our setup using bin/magento setup:static-content:deploy --theme=MyTheme/default de_CH fr_CH

Can confirm this issue is fixed in version 2.2.2, closing.

Thanks @wert2all!

Any news here? Still reproduced in 2.3.x 😕 commit was merged only to 2.2 branch

Still reproduced in 2.4.3