next-translate 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1126,6 +1126,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
1126
1126
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/alziqziq"><img src="https://avatars.githubusercontent.com/u/29282122?v=4?s=100" width="100px;" alt="Muhammad Al Ziqri"/><br /><sub><b>Muhammad Al Ziqri</b></sub></a><br /><a href="https://github.com/aralroca/next-translate/commits?author=alziqziq" title="Code">💻</a></td>
1127
1127
  <td align="center" valign="top" width="14.28%"><a href="http://teka.dev"><img src="https://avatars.githubusercontent.com/u/4443094?v=4?s=100" width="100px;" alt="Marcelo Oliveira"/><br /><sub><b>Marcelo Oliveira</b></sub></a><br /><a href="https://github.com/aralroca/next-translate/commits?author=marcelotk15" title="Code">💻</a></td>
1128
1128
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/SimplyComplexable"><img src="https://avatars.githubusercontent.com/u/8563846?v=4?s=100" width="100px;" alt="Zack Sunderland"/><br /><sub><b>Zack Sunderland</b></sub></a><br /><a href="https://github.com/aralroca/next-translate/commits?author=SimplyComplexable" title="Code">💻</a></td>
1129
+ <td align="center" valign="top" width="14.28%"><a href="http://andrewovens.com"><img src="https://avatars.githubusercontent.com/u/107420510?v=4?s=100" width="100px;" alt="Andrew Ovens"/><br /><sub><b>Andrew Ovens</b></sub></a><br /><a href="https://github.com/aralroca/next-translate/commits?author=aovens-quantifi" title="Code">💻</a></td>
1129
1130
  </tr>
1130
1131
  </tbody>
1131
1132
  </table>
package/lib/cjs/Trans.js CHANGED
@@ -11,6 +11,8 @@ function Trans(_a) {
11
11
  var _b = (0, useTranslation_1.default)(ns), t = _b.t, lang = _b.lang;
12
12
  var result = (0, react_1.useMemo)(function () {
13
13
  var text = t(i18nKey, values, { fallback: fallback, default: defaultTrans });
14
+ if (!text)
15
+ return text;
14
16
  if (!components || components.length === 0)
15
17
  return text;
16
18
  return (0, formatElements_1.default)(text, components);
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.tagParsingRegex = void 0;
26
27
  var react_1 = __importStar(require("react"));
27
- var tagRe = /<(\w+)>(.*?)<\/\1>|<(\w+)\/>/;
28
+ exports.tagParsingRegex = /<(\w+) *>(.*?)<\/\1 *>|<(\w+) *\/>/;
28
29
  var nlRe = /(?:\r\n|\r|\n)/g;
29
30
  function getElements(parts) {
30
31
  if (!parts.length)
@@ -36,7 +37,7 @@ function getElements(parts) {
36
37
  }
37
38
  function formatElements(value, elements) {
38
39
  if (elements === void 0) { elements = []; }
39
- var parts = value.replace(nlRe, '').split(tagRe);
40
+ var parts = value.replace(nlRe, '').split(exports.tagParsingRegex);
40
41
  if (parts.length === 1)
41
42
  return value;
42
43
  var tree = [];
package/lib/esm/Trans.js CHANGED
@@ -6,6 +6,8 @@ export default function Trans(_a) {
6
6
  var _b = useTranslation(ns), t = _b.t, lang = _b.lang;
7
7
  var result = useMemo(function () {
8
8
  var text = t(i18nKey, values, { fallback: fallback, default: defaultTrans });
9
+ if (!text)
10
+ return text;
9
11
  if (!components || components.length === 0)
10
12
  return text;
11
13
  return formatElements(text, components);
@@ -1,5 +1,5 @@
1
1
  import React, { cloneElement, Fragment } from 'react';
2
- var tagRe = /<(\w+)>(.*?)<\/\1>|<(\w+)\/>/;
2
+ export var tagParsingRegex = /<(\w+) *>(.*?)<\/\1 *>|<(\w+) *\/>/;
3
3
  var nlRe = /(?:\r\n|\r|\n)/g;
4
4
  function getElements(parts) {
5
5
  if (!parts.length)
@@ -11,7 +11,7 @@ function getElements(parts) {
11
11
  }
12
12
  export default function formatElements(value, elements) {
13
13
  if (elements === void 0) { elements = []; }
14
- var parts = value.replace(nlRe, '').split(tagRe);
14
+ var parts = value.replace(nlRe, '').split(tagParsingRegex);
15
15
  if (parts.length === 1)
16
16
  return value;
17
17
  var tree = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-translate",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.",
5
5
  "license": "MIT",
6
6
  "keywords": [