Skip to content

Commit 8784cb5

Browse files
committed
trans with nesting $t() and interpolation
1 parent 5cb73de commit 8784cb5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/i18n.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ i18n.init({
6565
transTest1: 'Another go <1>there</1>.',
6666
nestingKey1: 'This is key1 value and $t(nestedKey2)',
6767
nestedKey2: 'This is key2 value',
68+
nestingInterKey3: 'should work {{check_this}}',
6869
},
6970
},
7071
},
@@ -79,6 +80,7 @@ i18n.init({
7980
defaultVariables: {
8081
defaultInsert: 'first',
8182
defaultUp: 'second',
83+
check_this: '$t(nestedKey2)',
8284
},
8385
},
8486

test/trans.render.spec.jsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,3 +1095,25 @@ describe('trans with nesting $t()', () => {
10951095
`);
10961096
});
10971097
});
1098+
1099+
describe('trans with nesting $t() and interpolation', () => {
1100+
function TestComponent({ parent }) {
1101+
return (
1102+
<Trans
1103+
i18nKey="nestingInterKey3"
1104+
ns="other"
1105+
parent={parent}
1106+
tOptions={{ interpolation: { skipOnVariables: false } }}
1107+
/>
1108+
);
1109+
}
1110+
1111+
it('should render correct content', () => {
1112+
const { container } = render(<TestComponent />);
1113+
expect(container.firstChild).toMatchInlineSnapshot(`
1114+
<div>
1115+
should work This is key2 value
1116+
</div>
1117+
`);
1118+
});
1119+
});

0 commit comments

Comments
 (0)