Skip to content

Commit

Permalink
revert last optimization to address #2227
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Aug 15, 2024
1 parent 35d9757 commit 66fad4c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 23.12.7

- revert last optimization to address [2227](https://github.com/i18next/i18next/issues/2227)

## 23.12.6

- remove console.log statement [2227](https://github.com/i18next/i18next/issues/2227)
Expand Down
6 changes: 2 additions & 4 deletions i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -1459,10 +1459,8 @@
let optForCache = options;
if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
optForCache = {
formatParams: {
[options.interpolationkey]: options.formatParams[options.interpolationkey]
},
interpolationKey: options.interpolationkey
...optForCache,
[options.interpolationkey]: undefined
};
}
const key = lng + JSON.stringify(optForCache);
Expand Down
2 changes: 1 addition & 1 deletion i18next.min.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/Formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const createCachedFormatter = (fn) => {
const cache = {};
return (val, lng, options) => {
let optForCache = options;
// this cache optimization will only work for keys having 1 interpolated value
if (
options &&
options.interpolationkey &&
Expand All @@ -56,10 +57,8 @@ const createCachedFormatter = (fn) => {
options[options.interpolationkey]
) {
optForCache = {
formatParams: {
[options.interpolationkey]: options.formatParams[options.interpolationkey],
},
interpolationKey: options.interpolationkey,
...optForCache,
[options.interpolationkey]: undefined,
};
}
const key = lng + JSON.stringify(optForCache);
Expand Down

0 comments on commit 66fad4c

Please sign in to comment.