Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: i18next/react-i18next
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v14.0.3
Choose a base ref
...
head repository: i18next/react-i18next
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v14.0.4
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Feb 6, 2024

  1. Copy the full SHA
    2c4c4a7 View commit details
  2. 14.0.4

    adrai committed Feb 6, 2024
    Copy the full SHA
    ac3f71c View commit details
Showing with 51 additions and 8 deletions.
  1. +4 −0 CHANGELOG.md
  2. +2 −2 package-lock.json
  3. +1 −1 package.json
  4. +1 −1 react-i18next.js
  5. +1 −1 react-i18next.min.js
  6. +4 −3 src/TransWithoutContext.js
  7. +2 −0 test/i18n.js
  8. +36 −0 test/trans.render.spec.jsx
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 14.0.4

- fix interpolation of the count prop [1719](https://github.com/i18next/react-i18next/issues/1719)

### 14.0.3

- revert changes done in v14.0.2 since it breaks normal language change render updates
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-i18next",
"version": "14.0.3",
"version": "14.0.4",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "./index.d.mts",
2 changes: 1 addition & 1 deletion react-i18next.js
Original file line number Diff line number Diff line change
@@ -480,7 +480,7 @@
...i18n.options.interpolation.defaultVariables
};
}
const interpolationOverride = values ? tOptions.interpolation : {
const interpolationOverride = values || count !== undefined ? tOptions.interpolation : {
interpolation: {
...tOptions.interpolation,
prefix: '#$?',
2 changes: 1 addition & 1 deletion react-i18next.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/TransWithoutContext.js
Original file line number Diff line number Diff line change
@@ -351,9 +351,10 @@ export function Trans({
? { ...values, ...i18n.options.interpolation.defaultVariables }
: { ...i18n.options.interpolation.defaultVariables };
}
const interpolationOverride = values
? tOptions.interpolation
: { interpolation: { ...tOptions.interpolation, prefix: '#$?', suffix: '?$#' } };
const interpolationOverride =
values || count !== undefined
? tOptions.interpolation
: { interpolation: { ...tOptions.interpolation, prefix: '#$?', suffix: '?$#' } };
const combinedTOpts = {
...tOptions,
count,
2 changes: 2 additions & 0 deletions test/i18n.js
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ i18n.init({
deepKey1: 'value1',
},
transTestWithSelfClosing: 'interpolated component: <component/>',
bracketNotation: '{{count}}',
otherNotation: '#$?count?$#',
},
other: {
transTest1: 'Another go <1>there</1>.',
36 changes: 36 additions & 0 deletions test/trans.render.spec.jsx
Original file line number Diff line number Diff line change
@@ -193,6 +193,42 @@ describe('trans simple with custom html tag', () => {
});
});

describe('trans bracketNotation', () => {
function TestComponent() {
const numOfItems = 4;
return (
<Trans i18nKey="bracketNotation" count={numOfItems} />
);
}

it('should render correct content', () => {
const { container } = render(<TestComponent />);
expect(container.firstChild).toMatchInlineSnapshot(`
<div>
4
</div>
`);
});
});

describe('trans otherNotation', () => {
function TestComponent() {
const numOfItems = 4;
return (
<Trans i18nKey="otherNotation" count={numOfItems} />
);
}

it('should render correct content', () => {
const { container } = render(<TestComponent />);
expect(container.firstChild).toMatchInlineSnapshot(`
<div>
#$?count?$#
</div>
`);
});
});

describe('trans testTransKey1 singular', () => {
function TestComponent() {
const numOfItems = 1;