diff --git a/projects/js-packages/i18n-check-webpack-plugin/README.md b/projects/js-packages/i18n-check-webpack-plugin/README.md index 4abdde7ba00df..fbfb098b351e5 100644 --- a/projects/js-packages/i18n-check-webpack-plugin/README.md +++ b/projects/js-packages/i18n-check-webpack-plugin/README.md @@ -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: diff --git a/projects/js-packages/i18n-check-webpack-plugin/changelog/fix-i18n-check-docs b/projects/js-packages/i18n-check-webpack-plugin/changelog/fix-i18n-check-docs new file mode 100644 index 0000000000000..d46636facd63f --- /dev/null +++ b/projects/js-packages/i18n-check-webpack-plugin/changelog/fix-i18n-check-docs @@ -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. diff --git a/projects/js-packages/i18n-check-webpack-plugin/package.json b/projects/js-packages/i18n-check-webpack-plugin/package.json index f57dc3be39238..307f017a2f14d 100644 --- a/projects/js-packages/i18n-check-webpack-plugin/package.json +++ b/projects/js-packages/i18n-check-webpack-plugin/package.json @@ -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": { diff --git a/projects/js-packages/i18n-check-webpack-plugin/tests/__snapshots__/build.test.js.snap b/projects/js-packages/i18n-check-webpack-plugin/tests/__snapshots__/build.test.js.snap index 59cf332312086..8b8d785c2dc7f 100644 --- a/projects/js-packages/i18n-check-webpack-plugin/tests/__snapshots__/build.test.js.snap +++ b/projects/js-packages/i18n-check-webpack-plugin/tests/__snapshots__/build.test.js.snap @@ -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: diff --git a/projects/js-packages/i18n-check-webpack-plugin/tests/fixtures/known-problems/src/index.js b/projects/js-packages/i18n-check-webpack-plugin/tests/fixtures/known-problems/src/index.js index 1dc63ccd38ee9..6bbb0134998dc 100644 --- a/projects/js-packages/i18n-check-webpack-plugin/tests/fixtures/known-problems/src/index.js +++ b/projects/js-packages/i18n-check-webpack-plugin/tests/fixtures/known-problems/src/index.js @@ -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 ) {