magento2: Major 2.1.3 regression bug breaks js translations, caused by overly aggressive performance optimizations of the static content deployment
Preconditions
- Magento CE 2.1.3
- PHP 7.0.14
Steps to reproduce
- Install Magento CE 2.1.3 using composer
- Install a couple of language packs (for example one for nl_NL and fr_FR)
- Setup multiple storeviews, each one in a different language
- Put your store in production mode (I used the
--skip-compilation
flag) - Run
setup:static-content:deploy --theme=Magento/luma en_US nl_NL fr_FR
- Go to each storeview in the frontend and go to the ‘create an account’ page
- Don’t fill in the fields, just press the ‘Create an Account’ button
Expected result
- The warnings about the required fields are translated on each different storeview in its own language
Actual result
- The warnings about the required fields on all different storeviews are all in English (the first language of the
setup:static-content:deploy
command)
Discussion
Magento 2.1.3 has optimized the static content deployment so it only generates the content for the first language and then blindly copies that directory to the other requested locales. This is really great, because 99% of the files in those directories are always the same. Except for the javascript translations… And now we have this problem caused by this optimization.
More info
In Magento 2.1.2, if I take a diff of the nl_NL & fr_FR directories, I see 4 files which differ:
....pub/static/frontend/Vendor/theme $ diff -rwq nl_NL fr_FR
Files nl_NL/css/email-inline.css and fr_FR/css/email-inline.css differ
Files nl_NL/css/email.css and fr_FR/css/email.css differ
Files nl_NL/css/styles-m.css and fr_FR/css/styles-m.css differ
Files nl_NL/js-translation.json and fr_FR/js-translation.json differ
I’m not sure if the changes in the email css files are important, the changes in the styles-m.css files only differ by the order in which they are defined (which is weird, but whatever), but the most important file is that js-translation.json
file.
Workaround
You can work around this bug by executing the setup:static-content:deploy
command for every language separately:
php bin/magento setup:static-content:deploy --theme=Magento/luma en_US
php bin/magento setup:static-content:deploy --theme=Magento/luma nl_NL
php bin/magento setup:static-content:deploy --theme=Magento/luma fr_FR
But this means you can’t depend on the performance optimization which runs these processes in parallel, which was introduced in 2.1.1.
@ Magento team: seriously, can you actually test stuff before releasing them into a new version? We aren’t waiting on new “performance optimization” features, we just want bug fixes for now, not new features with new bugs.
@woosley-mg @benmarks: I expect this major bug the be resolved in maximum 2 weeks (or let’s make it 3 due to the upcoming holidays). Thank you!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 55
- Comments: 58 (36 by maintainers)
Commits related to this issue
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by deleted user 7 years ago
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by deleted user 7 years ago
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by deleted user 7 years ago
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by deleted user 7 years ago
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by deleted user 7 years ago
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 [fixed code style] — committed to magento/magento2 by deleted user 7 years ago
- MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by deleted user 7 years ago
- Merge pull request #803 from magento-tango/MAGETWO-62660 Bug fixes: * MAGETWO-62660: [GitHub] Overly aggressive performance optimizations of the static content deployment #7862 — committed to magento/magento2 by magicbunneh 7 years ago
- Implement workaround for deploying multi-lingual JS translations - See magento/magento2#7862 for details of core Magento issue affecting deployments. — committed to davidalger/capistrano-magento2 by davidalger 7 years ago
- Implement workaround for deploying multi-lingual JS translations - See magento/magento2#7862 for details of core Magento issue affecting deployments. - Issue #72 — committed to davidalger/capistrano-magento2 by davidalger 7 years ago
- Reverted 4f246bd; fix noted in release notes for Magento 2.1.8 was inaccurate See: https://github.com/magento/magento2/issues/7862#issuecomment-325845267 — committed to davidalger/capistrano-magento2 by davidalger 7 years ago
- Scrubbed workaround introduced in #72 to resolve issue affecting 2.1.3 and through 2.2.2 or possible up to but not including 2.3.0 Indicator of being fixed in 2.2.2 and later: https://github.com/mage... — committed to davidalger/capistrano-magento2 by davidalger 4 years ago
@hostep, thank you for your report. The issue is already fixed in 2.2.0
I can confirm this bug is still present in version 2.1.6. Will it be fixed in version 2.2?
This has nothing to do with nginx configs. Magento checks those files via the file system.
Same problem. Server: Ubuntu 16.04, Nginx 1.10, PHP 7, MySQL 5.7, Magento 2.1.3 CE clear. Command php
/var/www/html/bin/magento setup:static-content:deploy --theme Magento/luma ru_RU
don’t help. I think Magento 2 will never work well. Throughout the year, I’m trying to run project on Magento 2. Every step - errors in Magento 2.Hi @hostep
Thanks for reporting. We’ve created internal ticket MAGETWO-62660 to investigate and fix this issue.
I’m not 100% sure if this is the same bug, but after debugging the static content deployment process for a couple of hours, I found out that that in
Magento\Framework\Translate#setConfig()
on line 212,getId()
always returnsnull
. This is because the loaded themes don’t have atheme_id
in their_data
since they’re loaded from the filesystem (in 2.1.x, this code was inMagento\Theme\Model\Theme\Collection
) instead of the database. That leads to thisif
statement to always return true and never loading the theme translations.(I used a random commit for the links so the line numbers don’t change when the branch is updated.)
Closing as this was fixed somewhere in Magento 2.2.x
The only reason this ticket was still open is because it wasn’t fixed yet in Magento 2.1 But Magento 2.1 will be EOL after its final release 2.1.18 next week, so let’s just close this ticket.
Thx man! You save my day 😃
I think I know this error and I solved it by the following patch :
Thanks as always! ❤️
@chaohe / @hostep This is what I get for relying on the release notes! Ouch.
I’m reverting that change in the gem and including it in v0.7.1, which I’ll push up shortly.
There is a next release for 2.1? Do you know when?
This issue has already been fixed in develop branch. Internal ticket for ver. 2.1. - MAGETWO-63309 - it is planned for one of the next releases.
I re-cofirm @PascalBrouwers’s issue. The Translation class should not be a singleton I guess. Took me a while to understand why this happens.
Check in your server configuration that the jzon files are processed by Nginx as a static file.
Under the nginx/apache settings in plesk, I tried turning on “Serve static files directly by nginx” with the following default files active:
ac3 avi bmp bz2 css cue dat doc docx dts eot exe flv gif gz htm html ico img iso jpeg jpg js mkv mp3 mp4 mpeg mpg ogg pdf png ppt pptx qt rar rm svg swf tar tgz ttf txt wav woff woff2 xls xlsx zip xml json
Hi @hostep
We’ve added the bug and your workaround to Known Issues for both CE and EE Release Notes (Magento 2.1.3).
Thanks for your support!