-
Notifications
You must be signed in to change notification settings - Fork 52
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
make-json does not work for .jsx files #200
Comments
After doing some digging, I'm gonna follow up on my own issue here which seems to be closely related to #177 People compiling their JS/JSX/TS with Webpack are likely to run into this problem since it's not very obvious even after reading these two great articles: (1, 2). Basically,
... is not the same as the bundle file generated by Webpack that you enqueue. If you're like me and trying to auto-generate your In my case, the script that I am actually enqueuing is a Webpack bundle located at
After doing this, It looks like this issue is already being discussed elsewhere (#174, #127), but I think it goes without saying that parsing minified bundle files as a workaround is not ideal. |
@EvanShaw The MD5 hash issue is indeed being discussed elsewhere and is not trivial to solve. But I don't see why the command would not create any JSON file at all. Can you please clarify whether this is about the wrong file name issue or if no JSON files are actually created? |
@swissspidy Sorry for derailing a bit from the initial issue. JSON files are indeed not created by
Lines 133 - 149: // Find all unique sources this translation originates from.
$sources = array_map(
function ( $reference ) {
$file = $reference[0];
if ( substr( $file, - 7 ) === '.min.js' ) {
return substr( $file, 0, - 7 ) . '.js';
}
if ( substr( $file, - 3 ) === '.js' ) {
return $file;
}
return null;
},
$translation->getReferences()
); As it stands, |
just happened to me too. on my .po. note the .jsx extension:
src/components/AuthorInfo.jsx:9
dist/main.js
assets.php
things i tried:1 if i change the to .js in the .po file, it does generate a json but with the md5 of 'src/components/AuthorInfo.jsx'. ❌ 2 using |
The same thing happened to me. I'm bundling My Any workaround for this? Without it, my plugin options are basically untranslatable (my plugin settings page is built using GB components 😬 ) |
I have no problem generating
.pot
files for php and jsx files with the following command:wp i18n make-pot . languages/messages.pot
. Then after merging with my.po
files I get something like the following:jsx is parsed correctly and everything seems fine. However, when I run
wp i18n make-json languages --no-purge
, no files are created.Changing jsx extensions to js circumvents this issue, but I would expect if
make-pot
can parse jsx thenmake-json
can detect.po
comments ending in jsxThe text was updated successfully, but these errors were encountered: