Skip to content

Commit

Permalink
changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jul 16, 2021
1 parent 498b441 commit 34e5a7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 11.11.3

- Trans: parse first, then interpolate [1345](https://github.com/i18next/react-i18next/pull/1345)

### 11.11.2

- feat(typings): support readonly namespaces in TFuncKey [1340](https://github.com/i18next/react-i18next/pull/1340)
Expand Down
16 changes: 10 additions & 6 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,9 @@
}

getData(children);
var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread2(_objectSpread2({}, data), combinedTOpts), i18n.language);
var ast = c.parse("<0>".concat(interpolatedString, "</0>"));
var ast = c.parse("<0>".concat(targetString, "</0>"));

var opts = _objectSpread2(_objectSpread2({}, data), combinedTOpts);

function renderInner(child, node, rootReactNode) {
var childs = getChildren(child);
Expand All @@ -589,7 +590,7 @@
var reactNodes = getAsArray(reactNode);
var astNodes = getAsArray(astNode);
return astNodes.reduce(function (mem, node, i) {
var translationContent = node.children && node.children[0] && node.children[0].content;
var translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);

if (node.type === 'tag') {
var tmp = reactNodes[parseInt(node.name, 10)];
Expand All @@ -604,7 +605,8 @@
var isKnownComponent = _typeof(children) === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);

if (typeof child === 'string') {
mem.push(child);
var value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
mem.push(value);
} else if (hasChildren(child) || isValidTranslationWithChildren) {
var inner = renderInner(child, node, rootReactNode);
pushTranslatedJSX(child, inner, mem, i);
Expand Down Expand Up @@ -653,12 +655,14 @@
} else if (node.type === 'text') {
var wrapTextNodes = i18nOptions.transWrapTextNodes;

var _content = i18n.services.interpolator.interpolate(node.content, opts, i18n.language);

if (wrapTextNodes) {
mem.push(React__default.createElement(wrapTextNodes, {
key: "".concat(node.name, "-").concat(i)
}, node.content));
}, _content));
} else {
mem.push(node.content);
mem.push(_content);
}
}

Expand Down
Loading

0 comments on commit 34e5a7f

Please sign in to comment.