Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jul 6, 2022
1 parent c840421 commit eb4f22a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 11.18.0

- ability to add custom unescape function [1529](https://github.com/i18next/react-i18next/pull/1529)

### 11.17.4

- fix: UMD build [1527](https://github.com/i18next/react-i18next/issues/1527)
Expand Down
23 changes: 12 additions & 11 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,8 @@
}
};

var replace = ''.replace;
var es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
var unes = {
var matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g;
var htmlEntities = {
'&': '&',
'&': '&',
'&lt;': '<',
Expand All @@ -332,13 +331,14 @@
'&quot;': '"',
'&#34;': '"'
};
function unescape(un) {
return replace.call(un, es, cape);
}

function cape(m) {
return unes[m];
}
var unescapeHtmlEntity = function unescapeHtmlEntity(m) {
return htmlEntities[m];
};

var unescape = function unescape(text) {
return text.replace(matchHtmlEntity, unescapeHtmlEntity);
};

var defaultOptions = {
bindI18n: 'languageChanged',
Expand All @@ -347,7 +347,8 @@
transSupportBasicHtmlNodes: true,
transWrapTextNodes: '',
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
useSuspense: true
useSuspense: true,
unescape: unescape
};
var i18nInstance;
var I18nContext = react.createContext();
Expand Down Expand Up @@ -691,7 +692,7 @@
} else if (node.type === 'text') {
var wrapTextNodes = i18nOptions.transWrapTextNodes;

var _content = shouldUnescape ? unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
var _content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);

if (wrapTextNodes) {
mem.push(react.createElement(wrapTextNodes, {
Expand Down

0 comments on commit eb4f22a

Please sign in to comment.