5

After switching to the production mode, an error appeared in the console :

pub/static/adminhtml/Magento/backend/en_US/js-translation.json 404 (Not Found)
pub/static/adminhtml/Magento/backend/en_US/js-translation.json HTTP status: 404
    at XMLHttpRequest.xhr.onreadystatechange (text.min.js:8)

I was looking for a solution, I found such solutions:

bin/magento c:c
bin/magento c:f
rm -rf pub/static/*

and run

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

or

 php -d memory_limit=4G bin/magento setup:static-content:deploy en_US

And I'm trying this :

In vendor/magento/module-translation/Model/Json/PreProcessor.php

 $area = $this->areaList->getArea($areaCode);
 $area->load(\Magento\Framework\App\Area::PART_TRANSLATE);

needs to be:

$area = $this->areaList->getArea($areaCode);
$area->load(\Magento\Framework\App\Area::PART_DESIGN);
$area->load(\Magento\Framework\App\Area::PART_TRANSLATE);

But this did not help me, Magento still does not find the file :

pub/static/adminhtml/Magento/backend/en_US/js-translation.json

3 Answers 3

8

I used this command :

bin/magento setup:static-content:deploy --theme=Vendor/Theme en_US -f

This command created js-translation.json.

This solved my problem.

3
  • Not working for me in magento 2.3.6 version..
    – Nikul
    Commented Jun 25, 2021 at 8:44
  • 1
    Very helpful! This solved my problem after adding multi-language store views. I'm on Magento 2.4.5-p3. Commented Jun 27, 2023 at 23:41
  • @seanbreeden, I'm glad I could help you) Commented Jul 10, 2023 at 12:56
1

Solution not working for me either on Magento 2.4. The files not being generated and publishing static content throws an error

Error while translating phrase "%s" in file %s.

Very informative. When modifing code to display variables that should be substitued the problem is

Warning: MessageFormatter::formatMessage(): pattern syntax error (parse error at offset 3, after "${ ", before or at "$.visible } out") in /var/www/html/vendor/magento/framework/Phrase/Renderer/MessageFormatter.php on line 43
array(1) {
  [0]=>
  string(42) "${ $.visible } out of ${ $.total } visible"
}

and in the file is this

templates: {
  headerMsg: $t('${ $.visible } out of ${ $.total } visible')
}

It's in magento/magento-ui package.


magento/module-ui is 101.2.5

magento/module-translation is 100.4.5


What helps is to disable waning errors in PHP, change log level to error and above. But magento sets it's own level reporting E_ALL and in ErrorHandler trows an exception. On production I quite don't see reason for warnings to be this hard. The dirty fix is to modify app/bootstrap.php and set the

error_reporting(E_ALL);

to

error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING);
0

i was helped

bin/magento app:config:import
bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.