You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like comments in JSX are not properly parsed by the command in some cases like when they are placed before an embedded inline expression, it fails with the following error:
Could not parse file <FILE_NAME>: Unclosed { (line 19, column 0)
How to reproduce it
Create an example JSX file with the following content and locate it in a folder (in this example I named the file example.js and the folder /example):
importReactfrom'react';import{__}from'@wordpress/i18n';exportdefaultclassExampleextendsReact.Component{render(){return(<divclassName="example">{/* This is a comment */}{this.props.items.map((item)=>{return<divkey={item.id}>{item.name}</div>;})}<buttononClick={()=>{}}>{__('This is a button')}</button></div>);}}
NOTE: I managed to produce this issue with an empty block { } too, however, it works when adding any code, like for example { null } 🤔 .
Run command wp i18n make-pot example --ignore-domain --debug example.pot.
Observe that the command logs the error Could not parse file when parsing the file.
Observe that the POT file doesn't contain the This is a button string.
Expected result
Files that contain comments in JSX should be properly parsed.
In the previous example, the expected result in the POT file would be:
#: example.js:13
msgid "This is a button"
msgstr ""
Environment
PHP version: 7.3.11
WP-CLI 2.5.0
The text was updated successfully, but these errors were encountered:
Description
Looks like comments in JSX are not properly parsed by the command in some cases like when they are placed before an embedded inline expression, it fails with the following error:
How to reproduce it
example.js
and the folder/example
):NOTE: I managed to produce this issue with an empty block
{ }
too, however, it works when adding any code, like for example{ null }
🤔 .wp i18n make-pot example --ignore-domain --debug example.pot
.Could not parse file
when parsing the file.This is a button
string.Expected result
Files that contain comments in JSX should be properly parsed.
In the previous example, the expected result in the POT file would be:
Environment
The text was updated successfully, but these errors were encountered: