-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
js-translation.json not picking up theme translations 2.1.3 / 2.1.4 #8508
Comments
Update on this (spent all day debugging):
$this->_config['theme'] = $this->_viewDesign->getDesignTheme()->getId(); returns null. So in the function _loadThemeTranslation() it fails because $this->_config['theme'] is not set (it's null). It should be returning the theme Id (in my case ID 4). So there's something the matter with Hope this helps. Is there a quick workaround I wonder? Thanks |
Duplicate of #8459 Thom |
Hello! Please write your steps and commands for two methods: create language pack and create theme translations. |
Hello. I have also experienced the js-translation.json not building itself properly. Deleting the file does rebuild it but still fails to pick up theme translations (not 100% sure a "bin/magento setup:static-content:deploy..." works on my custom theme). I have no idea what is meant by "Please write your steps and commands for two methods: create language pack and create theme translations". I have noticed some quite short and disrespectful comments on GitHub. I can appreciate people's frustration but that isn't going to solve anything. I've given up valuable company time to try highlight this particular problem. I haven't tested in versions previous to 2.1.3. I will try do this tomorrow. Thanks |
I see the same problem, but all commands are executed too different. So I asked to write all the steps that you did when deploying the language.
Method 2: Add file ru_RU.csv to my theme. Path: app/design/frontend/Agestor/default/i18n/.
Right? Two methods same official documentation. Don't works... js-translation.json - empty... |
Hi Flamestyle / All. You look to be doing everything correctly. I'm assuming you've set your Locale (In Stores > Configuration > General - Locale) to ru_RU? However in my case the language pack is being picked up and the js-translation.json is not empty. My Locale is set to en_GB. The code in my language.xml is set to en_GB. It's the Theme translations that I want to pick up in my js-translation.json i.e. AND I THINK I'VE FOUND THE PROBLEM TO MY ISSUE: In vendor/magento/module-translation/Model/Json/PreProcessor.php
needs to be:
It needs to load the design before loading the translations. The above insertion then works for me! So hopefully Magento will pick up on this soon. When you look at how other areas are loaded for example: You'll see: $area = $this->_areaList->getArea($this->appState->getAreaCode()); The design must be present before the translations are loaded. Thanks |
@tadhgbowe, yes General - Locale include ru_RU. |
Hello again, I only created the language pack to see if my js-translation.json could pick up the translations from there. And yes that worked. But I never wanted to create a language pack. I simply wanted to be able to handle everything from my theme. So in my example I can now remove the language pack. I only used it to prove that js translations worked when in a language pack and not from my theme. My theme code (in database table theme) is called Training/default. If I run all the following commands it works fine: rm -rf pub/static/* Please Note: When you setup a theme you can't just have an i18n folder and nothing else. The static-content:deploy will error saying that the Theme doesn't exist. You have to have some wee/css/source files in there for it to deploy for you. Thanks |
Hello, @tadhgbowe! For me prefer to be able to handle everything from my theme too. |
Hi @Flamestyle and all others who read this. Obviously this is a small Magento bug and hopefully they will pick up on this soon. We can't change the core file vendor/magento/module-translation/Model/Json/PreProcessor.php for obvious reasons. For a workaround you can consider using a before Plugin, a Preference or as you'll see below the PreProcessor is already a part of the module-translation di.xml. In your code/[Vendor]/[Module Name]/etc/di.xml you can use:
All the best, |
I have the same problem. But this fix doesn't work for me.... |
@carfantasy Which of the two? Write all your steps so that can analyze. |
Hi, I did: this was not the solution, so I did: In vendor/magento/module-translation/Model/Json/PreProcessor.php
needs to be:
rm -rf pub/static/* Still not the solution.... |
Hi @carfantasy, First you need to check that your Stores > Configuration > General > Locale Options : the Locale for you needs to be set to Dutch (Netherlands). Secondly you need to make sure that your theme has the correct i18n/nl_NL.csv file. So it should live in a folder like app/design/frontend/[Theme/Vendor namespace]/[Theme e.g. default]/i18n With all the caches enabled you should only need to refresh the translations cache. You can also simply delete the js-translation.json in your pub/static/frontend/[Theme/Vendor namespace]/[Theme]/nl_NL folder. When the page loads (for example the basket page), there should be a call to build the js-translation.json. If it's not generating a js-translation.json at all then I would stick on some debug in vendor/magento/module-translation/Model/Json/PreProcessor.php process function. It should go in here. If it isn't then that's another Magento bug. I've never had a problem it not entering this piece of code. Please Note: If you have a language pack installed those translations will win over any theme and module translation phrases. My fix was specifically targeted at theme i18n folder translations e.g. [Theme]/i18n/en_GB.csv. Thanks |
Hi @tadhgbowe I did all things you mentioned. When I do Stores > Configuration > General > Locale Options : the Locale for you needs to be set to Dutch (Netherlands). The Java script at the backend crashed. When I put it back in en_US the Java workts but there is missing tekst, My admin login is also set to en_US and still tekst is missing. I will try do delete the theme files and run setup again. Than set to blank theme. Maybe this solves the issue... |
Hi @carfantasy, If your javascript is crashing that definitely sounds bad. It might be worth trying it out on a brand new install of Magento. I've been used CE 2.1.4. I hope you get it working. Kind regards, |
Hi @carfantasy and anybody else tuning in. I think it's worth noting that when you make translation changes that require a js-translation.json rebuild, to test that the changes have come through okay:
Happy coding (if there's such a thing) :-) |
I've tested and problem persists also in Version 2.1.6I found the problem mostly in Checkout |
here too in 2.1.6 |
Hi. I Try reproduce this bug. (Maybe i use incorrect steps, if yes please correct me) My steps for reproduce:
AR: Displayed "You have no items in your shopping test message. Note: It`s correct behaviour for this case. |
Hi K7Triton, Thanks for the message. That's not the correct area I was talking about. I was focusing on the min-cart overlay in the header of the page. When you click on the basket icon (beside the search bar) you get a little overlay to say "You have no items in your shopping cart.". The area you mention is built from a .pthml template file. They work fine. It's the .html knockout generated translations that get stuck :-) |
@tadhgbowe I reproduce this bug. |
Hi @k7triton. Great! The fix is below. Sorry I don't have time to follow up myself. What would be even more amazing is to be able to track MAGETWO-69601 somewhere. When the ticket has been resolved it would be great if the original source (i.e. here) could be updated with the Magento release versions that contained the fix. For people who stumble across this post in the future they can then clearly see what version it was fixed in. Right now it's quite fuzzy. Cheers. T In vendor/magento/module-translation/Model/Json/PreProcessor.php
needs to be:
It needs to load the design before loading the translations. The above insertion then works for me! So hopefully Magento will pick up on this soon. |
Brilliant!!! I had issue with all translation in the mini-cart and @tadhgbowe fix is working perfectly. Now all my translation added to my theme are working! |
For me this issue still exists on Magento 2.2.2 production mode, I am using Valet+ on MacOSX. Tried to fix it as suggested by @Tomasz-Silpion but issue cannot be resolved. |
Still same issue in 2.2.3, not tested >=2.2.4 yet js-translation.json still just contains [] |
In Magento 2.2.5, And I manually added the fix to it, followed all the steps for clearing cache in Theme translations are still not added to I can't explain why the fix went away on 2.2.5 branch... How is this even possible ? |
i also followed all step but problem still in Magento 2.2.5 |
For all of you still struggling with this issue (like myself) here is the fix proposed in module format: |
Hi @engcom-backlog-tomash. Thank you for working on this issue.
|
Hi @engcom-backlog-nazar. Thank you for working on this issue.
|
Hi @tadhgbowe Thank you for your report. The fix will be available with the upcoming 2.3.0 release. |
I'm on Magento 2.3.5 and I have this issue. The solutions presented do not help 😢 |
Still facing the issue on magento 2.3.5 |
Same here for 2.3.4. |
Folks, this issue was closed because the original reported issue was fixed in Magento 2.2.2: #8508 (comment) If you still run against this issue (or maybe a very similar one) please open a new ticket with exact steps of how to reproduce on a clean Magento installation. Doing it this way will get you quicker help then complaining on a 3-year old ticket. Thanks! 🙂 |
We still have a problem in 2.3.5, that the translation "items" is not picked up and so not included into the
Problem seems to be at least in that version *.phtml files are not scanned for JS translations. Not sure how it is with 2.4.2 As a workaround, one can createa file such as
and add all the missing translationed strings :-(
|
Hello. Apologies is reported before. I couldn't see it.
My theme translation file is not appearing in certain locations. For example the mini cart overlay and the cart is empty it says "You have no items in your shopping cart."
In my theme I have the translation "You have no items in your shopping basket.". When I go to the cart page I can see underneath the main content title "You have no items in your shopping basket.". So I know it's working. However when I hover over the mini cart in the header the overlay continues to say "You have no items in your shopping cart."
Tried on 2.1.3 and 2.1.4 community edition.
I have tried a static deploy, deleted the js-translation.json file itself. No joy.
Question: Does the js-translation.json not pick up theme translations?
Preconditions
Locale set to en_GB - English (United Kingdom)
Create a new theme. Enable this in the backend via Content > Design - Configuration.
Create a i18n/en_GB.csv file with the above translation:
"You have no items in your shopping cart.","You have no items in your shopping basket."
Refresh block, page and translation caches.
Steps to reproduce
Go to cart page /onepage/cart. In the main content area underneath Shopping Cart I can see my translation "You have no items in your shopping basket.". However the mini-cart overlay doesn't display the new translation.
Expected result
The empty mini-cart overlay should translate to "You have no items in your shopping basket."
Actual result
The empty mini-cart overlay continues to display the core translation "You have no items in your shopping cart."
OTHER NOTES/OBSERVATIONS/TESTS:
Thanks
T
The text was updated successfully, but these errors were encountered: