Closed yuliyan closed 2 years ago
This also came up in:
Noting that we switched to the .min.js file extension to prevent the built files from being handled by wp.com's JS minimization script, which started breaking when we dropped IE 11 (thus output into more modern JS).
This is apparently expected behavior for the make-pot CLI command:
[--exclude=
] [...] The following files and folders are always excluded: node_modules, .git, .svn, .CVS, .hg, vendor, *.min.js.
from https://developer.wordpress.org/cli/commands/i18n/make-pot/
I have in my mind that we checked GlotPress and confirmed the strings were there? If so, make-pot isn't the issue (I wouldn't think). If not, then we need to figure out something—either via make-pot or Systems re the wp.com need for .min.js that pushed us this way.
@kraftbj, I was able to get make-pot
pick up the strings from the JS files locally by simply renaming the file from editor.min.js
to editor.js
, which makes me think that the min
suffix is what's causing it.
Previously, there was a problem with the translation function names not being preserved in the minified output, but that got resolved in https://github.com/Automattic/jetpack/commit/1e56ff33dae8ef84c23d8621b30f6e974f32ab2a and by inspecting the plugin files I can confirm that __
function names are indeed preserved in the output files.
I'm not familiar with the reason why .min.js
is needed on WP.com, but if that's the case, a possible workaround could be to have two copies of the same JS files with different filenames in the release, i.e. to have both editor.min.js
and editor.js
.
I'm not familiar with the reason why .min.js is needed on WP.com
WordPress.com has an automatically minimizing process for JS upon being served to a client. That process assumes ES5 code. When we dropped IE 11 support, we started shipping ES6 code which WordPress.com's minimizing function chokes on (thus breaking blocks on WordPress.com with the same code committed there as in Jetpack).
Systems said that we should update the file name to min.js
, which the server ignores for that script.
Duplication is an okay immediate solution to get translations back for customers that we have control over, but I don't like it as a long-term solution as it doubles the JS payload we're shipping to customers with no benefit (beyond hacking around ecosystem issues).
tl;dr duplicate files is okay immediately but I'll task my team (or myself) to investigate further the make-pot
or Systems routes towards a different solution.
but I don't like it as a long-term solution as it doubles the JS payload we're shipping to customers with no benefit (beyond hacking around ecosystem issues).
"Shipping to customers" as in including both the minified and non-minifed built JS files in the Jetpack plugin? Or "shipping to customers" thinking that visitors to the site would get served both copies? To be clear, the latter would not happen.
Confirm, the latter wouldn't happen. I'd not want to ship too much extra to sites in the plugin upgrade routine.
Do you have any update on this issue?
@yuliyan We've been discussing potential solutions here: p9dueE-3Gb-p2
We'd be happy to have you chime in on that discussion!
I think that #21748 fixed this entirely after all. As far as I can tell none of the files that were being processed by gulp use @wordpress/i18n
(and now we've switched them to being processed by Webpack anyway).
Impacted plugin
Jetpack
Steps to Reproduce
wp i18n make-pot .
*.min.js
files are missing..min
suffix from the filename of any of the JS files that contain translatable strings (e.g._inc/blocks/editor.min.js
) and runwp i18n make-pot .
again.A clear and concise description of what you expected to happen.
AFAIK, the plugin directory is using the same (or pretty similar) approach to
wp i18n make-pot .
to generate POT file for a plugin and import into its translate.wordpress.org project. By default, themake-pot
command excludes some files and directories from scanning, including*.min.js
files. As a result:.min.js
are no longer being generated, because none of the strings have reference to such file.Other information
.min
suffix introduced in: https://github.com/Automattic/jetpack/commit/be80d269a407518138060e8417c522e051d58b9a Related issue: https://github.com/Automattic/jetpack/issues/21204