Commit bd1068f
Keep translators comments in the built bundles
The make-pot run on develop reported 27 strings with placeholders and no
`translators:` comment, and every one of them is in build/*.bundle.js - none
in PHP. Adding those comments to src/ would have had no effect: Terser's
default `format.comments` keeps only license banners, so the comments were
being stripped before `wp i18n make-pot` ever saw the bundle. The result
would have been 27 comments written, a rebuild, and no change to either the
warnings or the POT.
Verified with a real webpack run using this repo's exact terserOptions:
current config comment stripped, LICENSE.txt emitted
+ format.comments = /translators:/i comment kept, LICENSE.txt emitted
+ extractComments: false as well comment kept, LICENSE.txt dropped
So only the format.comments line is added. @wordpress/scripts also sets
extractComments: false in its own config, but copying that here would stop
the 8 *.bundle.js.LICENSE.txt files being emitted for no benefit - preserving
a comment and extracting one are separate things.
Confirmed end to end that make-pot then picks it up from minified output,
which is the part that was not obvious: Terser keeps the comment on its own
line ahead of the statement, and make-pot associates it correctly.
#. translators: 1: current issue number, 2: total issues
#: build/b.bundle.js:4
#, js-format
msgid "Issue %1$d of %2$d"
The warning disappears for that string, and both the `#.` comment and the
`#,` flag are kept by make-pot.yml's diff filter, so documenting these
strings will correctly be detected as a POT change and raise the update PR.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LoLgW7oFjBPxGea9kiZJ21 parent cc72684 commit bd1068f
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
72 | 82 | | |
73 | 83 | | |
74 | 84 | | |
| |||
0 commit comments