Skip to content
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

i18n-check-webpack-plugin: Update docs #35452

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading