Skip to content

Commit

Permalink
fix #33: i18next-icu incompatible with react-i18next
Browse files Browse the repository at this point in the history
I also folded in the fix from #32  to index.d.ts/README.md

Co-Authored-By: Jonas Woerlein <[email protected]>
  • Loading branch information
cellog and tngwoerleij committed Feb 28, 2021
1 parent 21e7b93 commit 4d39d95
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 1,207 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ i18next.use(ICU).init(i18nextOptions);
// memoize if not having a lookup and just using the key fallback as value
memoizeFallback: false,

// array or single object of loaded 'i18next-icu/locale-data
localeData: null,

// which events should clear the cache, can be set to false or string of events separated by " "
bindI18n: '',

Expand Down
8 changes: 7 additions & 1 deletion i18nextICU.js
Original file line number Diff line number Diff line change
Expand Up @@ -4427,7 +4427,13 @@

try {
if (!fc) {
fc = new IntlMessageFormat(res, lng, this.formats);
// without ignoreTag, react-i18next <Trans> translations with <0></0> placeholders
// will fail to parse, as IntlMessageFormat expects them to be defined in the
// options passed to fc.format() as { 0: (children) => string }
// but the replacement of placeholders is done in react-i18next
fc = new IntlMessageFormat(res, lng, this.formats, {
ignoreTag: true
});
if (this.options.memoize && (this.options.memoizeFallback || !info || hadSuccessfulLookup)) setPath(this.mem, memKey, fc);
}

Expand Down
2 changes: 1 addition & 1 deletion i18nextICU.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 4d39d95

Please sign in to comment.