Skip to content

Commit

Permalink
i18n-check-webpack-plugin: Update docs
Browse files Browse the repository at this point in the history
A change in some tooling (babel? terser?) seems to have broken one of
the fixes recommended in the package's docs, so stop recommending that
fix.

It's something in #26716, according to `git bisect`, but I couldn't
figure out what in there specifically changed.
  • Loading branch information
anomiex committed Feb 5, 2024
1 parent b140319 commit 5e4a761
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
10 changes: 1 addition & 9 deletions projects/js-packages/i18n-check-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,11 @@ const
/* translators: This is a good example. */
example = __( 'Example', 'domain' );
```
In some cases even the assignment may be dropped. In that case, you can attach the comment directly to the function call, or inside a multi-line function call:
In some cases even the assignment may be dropped. In that case, you can attach the comment directly to the function call:
```js
const example =
/* translators: This is a good example. */
__( 'Example', 'domain' );

const example2 = __(
/* translators: This is a good example. */
'Example',
'domain'
);

const example3 = __( /* translators: This won't work. The comment must be on a line after the `__(`. */ 'Example', 'domain' );
```

Similarly in jsx, a comment placed like this may wind up misplaced:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

At some point a change in the toolchain (babel? terser?) broke one of the possible fixes for expression movement. Update the docs to stop recommending that fix.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/i18n-check-webpack-plugin",
"version": "1.1.5",
"version": "1.1.6-alpha",
"description": "A Webpack plugin to check that WordPress i18n hasn't been mangled by Webpack optimizations.",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/i18n-check-webpack-plugin/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,15 @@ exports[`Webpack \`known-problems\`: Webpack build stats 1`] = `
{
"errors": [
{
"message": "main.js:2:92: msgid argument is not a string literal: __(o?"Foo is set":"Foo is not set","domain")",
"message": "main.js:3:148: msgid argument is not a string literal: __(o?"Foo is set":"Foo is not set","domain")",
},
{
"message": "main.js: Translator comments have gone missing for "The comment will be lost when the assignment is merged into the above const" (context "context")
- Translators: This comment will be lost",
},
{
"message": "main.js: Translator comments have gone missing for "This is another workaround" (context "context")
- Translators: This comment will be in the source but not detected for the right message.",
},
{
"message": "main.js: Optimization seems to have broken the following translation strings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ function constCombining() {
/* Translators: This comment will not be lost */
_x( 'This is the workaround', 'context', 'domain' );

return { bugged, fixed };
const bugged2 =
_x(
/* Translators: This comment will be in the source but not detected for the right message. */
'This is another workaround', 'context', 'domain'
);

const bugged3 = __( 'This will get the above comment', 'domain' );

return { bugged, fixed, bugged2, bugged3 };
}

function conditionals( foo, bar ) {
Expand Down

0 comments on commit 5e4a761

Please sign in to comment.