Repository: i18next/i18next-parser
Pull request #385 (2021-07-27 12:33:44)

Bump @babel/cli from 7.14.5 to 7.14.8
Bumps [@babel/cli](https://github.com/babel/babel/tree/HEAD/packages/babel-cli) from 7.14.5 to 7.14.8.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/babel/babel/releases"><code>@​babel/cli</code>'s releases</a>.</em></p>
<blockquote>
<h2>v7.14.8 (2021-07-20)</h2>
<p>Thanks <a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>, <a href="https://github.com/jaeseokk"><code>@​jaeseokk</code></a> and <a href="https://github.com/nme077"><code>@​nme077</code></a> for your first PRs!</p>
<h4>:eyeglasses: Spec Compliance</h4>
<ul>
<li><code>babel-helper-create-class-features-plugin</code>, <code>babel-plugin-proposal-class-static-block</code>, <code>babel-plugin-transform-new-target</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13560">#13560</a> fix(class-properties): replace <code>new.target</code> in static properties with <code>undefined</code> (<a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>)</li>
</ul>
</li>
<li><code>babel-parser</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13088">#13088</a> Fix await binding error within static block (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13531">#13531</a> fix: disallow computed <code>async</code>/<code>get</code>/<code>set</code> keyword (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-helper-module-transforms</code>, <code>babel-helper-simple-access</code>, <code>babel-plugin-transform-modules-commonjs</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13258">#13258</a> Fix const violations in ESM imports when transformed to CJS (<a href="https://github.com/overlookmotel"><code>@​overlookmotel</code></a>)</li>
</ul>
</li>
</ul>
<h4>:bug: Bug Fix</h4>
<ul>
<li><code>babel-parser</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13575">#13575</a> Update babel-parser.d.ts (<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13548">#13548</a> Fix  parser <code>strictMode</code> option (<a href="https://github.com/overlookmotel"><code>@​overlookmotel</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13573">#13573</a> Fix issue to allow module block in member expression (<a href="https://github.com/nme077"><code>@​nme077</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13521">#13521</a> Overhaul comment attachment (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13534">#13534</a> Async do expression should start at async (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-plugin-transform-arrow-functions</code>, <code>babel-traverse</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/12344">#12344</a> Fix arrow transformation when <code>arguments</code> is defined as variable (<a href="https://github.com/snitin315"><code>@​snitin315</code></a>)</li>
</ul>
</li>
<li><code>babel-traverse</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13527">#13527</a> fix: accept duplicated import/variable in different module (<a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>)</li>
</ul>
</li>
<li><code>babel-types</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13525">#13525</a> fix(babel-types): accept <code>UnaryExpression</code> in <code>TSLiteralType</code> (<a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13500">#13500</a> Add typeParameters to tagged template visitor keys (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
</ul>
<h4>:nail_care: Polish</h4>
<ul>
<li><code>babel-core</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13515">#13515</a> Fix config validation message typo (<a href="https://github.com/jaeseokk"><code>@​jaeseokk</code></a>)</li>
</ul>
</li>
<li><code>babel-cli</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13508">#13508</a> fix: sync default_extensions to babel-cli usage (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
</ul>
<h4>:memo: Documentation</h4>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13562">#13562</a> Fix <code>make generate-standalone</code> -&gt; <code>make build-standalone</code> (<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>)</li>
</ul>
<h4>:house: Internal</h4>
<ul>
<li><code>babel-helpers</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13522">#13522</a> minor improvement to gulp generate-runtime-helpers error message (<a href="https://github.com/lightmare"><code>@​lightmare</code></a>)</li>
</ul>
</li>
</ul>
<h4>:running_woman: Performance</h4>
<ul>
<li><code>babel-parser</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13521">#13521</a> Overhaul comment attachment (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
</ul>
<h4>Committers: 12</h4>
<ul>
<li>Babel Bot (<a href="https://github.com/babel-bot"><code>@​babel-bot</code></a>)</li>
<li>Bogdan Savluk (<a href="https://github.com/zxbodya"><code>@​zxbodya</code></a>)</li>
<li>Federico Ciardi (<a href="https://github.com/fedeci"><code>@​fedeci</code></a>)</li>
<li>Huáng Jùnliàng (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/babel/babel/blob/main/CHANGELOG.md"><code>@​babel/cli</code>'s changelog</a>.</em></p>
<blockquote>
<h2>v7.14.8 (2021-07-20)</h2>
<h4>:eyeglasses: Spec Compliance</h4>
<ul>
<li><code>babel-helper-create-class-features-plugin</code>, <code>babel-plugin-proposal-class-static-block</code>, <code>babel-plugin-transform-new-target</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13560">#13560</a> fix(class-properties): replace <code>new.target</code> in static properties with <code>undefined</code> (<a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>)</li>
</ul>
</li>
<li><code>babel-parser</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13088">#13088</a> Fix await binding error within static block (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13531">#13531</a> fix: disallow computed <code>async</code>/<code>get</code>/<code>set</code> keyword (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-helper-module-transforms</code>, <code>babel-helper-simple-access</code>, <code>babel-plugin-transform-modules-commonjs</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13258">#13258</a> Fix const violations in ESM imports when transformed to CJS (<a href="https://github.com/overlookmotel"><code>@​overlookmotel</code></a>)</li>
</ul>
</li>
</ul>
<h4>:bug: Bug Fix</h4>
<ul>
<li><code>babel-parser</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13575">#13575</a> Update babel-parser.d.ts (<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13548">#13548</a> Fix  parser <code>strictMode</code> option (<a href="https://github.com/overlookmotel"><code>@​overlookmotel</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13573">#13573</a> Fix issue to allow module block in member expression (<a href="https://github.com/nme077"><code>@​nme077</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13521">#13521</a> Overhaul comment attachment (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13534">#13534</a> Async do expression should start at async (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
<li><code>babel-plugin-transform-arrow-functions</code>, <code>babel-traverse</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/12344">#12344</a> Fix arrow transformation when <code>arguments</code> is defined as variable (<a href="https://github.com/snitin315"><code>@​snitin315</code></a>)</li>
</ul>
</li>
<li><code>babel-traverse</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13527">#13527</a> fix: accept duplicated import/variable in different module (<a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>)</li>
</ul>
</li>
<li><code>babel-types</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13525">#13525</a> fix(babel-types): accept <code>UnaryExpression</code> in <code>TSLiteralType</code> (<a href="https://github.com/colinaaa"><code>@​colinaaa</code></a>)</li>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13500">#13500</a> Add typeParameters to tagged template visitor keys (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
</ul>
<h4>:nail_care: Polish</h4>
<ul>
<li><code>babel-core</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13515">#13515</a> Fix config validation message typo (<a href="https://github.com/jaeseokk"><code>@​jaeseokk</code></a>)</li>
</ul>
</li>
<li><code>babel-cli</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13508">#13508</a> fix: sync default_extensions to babel-cli usage (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
</ul>
<h4>:memo: Documentation</h4>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13562">#13562</a> Fix <code>make generate-standalone</code> -&gt; <code>make build-standalone</code> (<a href="https://github.com/sosukesuzuki"><code>@​sosukesuzuki</code></a>)</li>
</ul>
<h4>:house: Internal</h4>
<ul>
<li><code>babel-helpers</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13522">#13522</a> minor improvement to gulp generate-runtime-helpers error message (<a href="https://github.com/lightmare"><code>@​lightmare</code></a>)</li>
</ul>
</li>
</ul>
<h4>:running_woman: Performance</h4>
<ul>
<li><code>babel-parser</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13521">#13521</a> Overhaul comment attachment (<a href="https://github.com/JLHwung"><code>@​JLHwung</code></a>)</li>
</ul>
</li>
</ul>
<h2>v7.14.7 (2021-06-21)</h2>
<h4>:bug: Bug Fix</h4>
<ul>
<li><code>babel-plugin-proposal-object-rest-spread</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13483">#13483</a> Don't hoist template literal keys in <code>object-rest-spread</code> (<a href="https://github.com/lala7573"><code>@​lala7573</code></a>)</li>
</ul>
</li>
<li><code>babel-plugin-transform-destructuring</code>
<ul>
<li><a href="https://github-redirect.dependabot.com/babel/babel/pull/13482">#13482</a> Don't hoist template strings from destructuring keys (<a href="https://github.com/lala7573"><code>@​lala7573</code></a>)</li>
</ul>
</li>
<li><code>babel-traverse</code></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/babel/babel/commit/e59178024431aa2cdfecd5b1694088edd1ced8a2"><code>e591780</code></a> v7.14.8</li>
<li><a href="https://github.com/babel/babel/commit/90d5eb7f2f2c699019aab2d5388ec1e8f3f469d2"><code>90d5eb7</code></a> fix: sync default_extensions to babel-cli usage (<a href="https://github.com/babel/babel/tree/HEAD/packages/babel-cli/issues/13508">#13508</a>)</li>
<li>See full diff in <a href="https://github.com/babel/babel/commits/v7.14.8/packages/babel-cli">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@babel/cli&package-manager=npm_and_yarn&previous-version=7.14.5&new-version=7.14.8)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/dist/transform.js b/dist/transform.js
index c07e754..44f857f 100644
--- a/dist/transform.js
+++ b/dist/transform.js
@@ -294,6 +294,11 @@ i18nTransform = /*#__PURE__*/function (_Transform) {(0, _inherits2["default"])(i
 
       } else {
         text = JSON.stringify(contents, null, this.options.indentation) + '\n';
+        // Convert non-ASCII characters to unicode escape sequence
+        text = text.replace(
+        /[\u007F-\uFFFF]/g,
+        function (chr) {return "\\u".concat("0000".concat(chr.charCodeAt(0).toString(16)).substr(-4));});
+
       }
 
       if (this.options.lineEnding === 'auto') {
diff --git a/src/transform.js b/src/transform.js
index 7436d14..39140c5 100644
--- a/src/transform.js
+++ b/src/transform.js
@@ -294,6 +294,11 @@ export default class i18nTransform extends Transform {
       })
     } else {
       text = JSON.stringify(contents, null, this.options.indentation) + '\n'
+      // Convert non-ASCII characters to unicode escape sequence
+      text = text.replace(
+        /[\u007F-\uFFFF]/g,
+        (chr) => `\\u${`0000${chr.charCodeAt(0).toString(16)}`.substr(-4)}`
+      )
     }
 
     if (this.options.lineEnding === 'auto') {
diff --git a/yarn.lock b/yarn.lock
index 8b1d9f3..fa7f884 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3,9 +3,9 @@
 
 
 "@babel/cli@^7.0.0":
-  version "7.14.5"
-  resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.14.5.tgz#9551b194f02360729de6060785bbdcce52c69f0a"
-  integrity sha512-poegjhRvXHWO0EAsnYajwYZuqcz7gyfxwfaecUESxDujrqOivf3zrjFbub8IJkrqEaz3fvJWh001EzxBub54fg==
+  version "7.14.8"
+  resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.14.8.tgz#fac73c0e2328a8af9fd3560c06b096bfa3730933"
+  integrity sha512-lcy6Lymft9Rpfqmrqdd4oTDdUx9ZwaAhAfywVrHG4771Pa6PPT0danJ1kDHBXYqh4HHSmIdA+nlmfxfxSDPtBg==
   dependencies:
     commander "^4.0.1"
     convert-source-map "^1.1.0"


Test patch:
diff --git a/test/parser.test.js b/test/parser.test.js
index af268fa..947b126 100644
--- a/test/parser.test.js
+++ b/test/parser.test.js
@@ -990,6 +990,31 @@ describe('parser', () => {
       i18nextParser.end(fakeFile)
     })
 
+    it('writes non-breaking space output to json', (done) => {
+      let result
+      const expected = '{\n  "nbsp": "One\\u00a0Two\\u00a0Three"\n}\n'
+
+      const i18nextParser = new i18nTransform({
+        output: 'locales/$LOCALE/$NAMESPACE.json',
+      })
+      const fakeFile = new Vinyl({
+        contents: Buffer.from("t('nbsp', 'One\\u00A0Two\\u00a0Three')"),
+        path: 'file.js',
+      })
+
+      i18nextParser.on('data', (file) => {
+        if (file.relative.endsWith(path.normalize('en/translation.json'))) {
+          result = file.contents.toString('utf8')
+        }
+      })
+      i18nextParser.once('end', () => {
+        assert.equal(result, expected)
+        done()
+      })
+
+      i18nextParser.end(fakeFile)
+    })
+
     it('supports outputing to yml', (done) => {
       let result
       const i18nextParser = new i18nTransform({