Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Aug 22, 2023
1 parent 079938c commit a3a0bf0
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 72 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 13.2.0

- Don't use defaults prop as default key [1664](https://github.com/i18next/react-i18next/pull/1664)

### 13.1.2

- postpone usage of newer ES syntax
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-testing-library": "^5.11.0",
"husky": "^8.0.3",
"i18next": "^23.2.10",
"i18next": "^23.4.5",
"jest": "^24.8.0",
"jest-cli": "^24.8.4",
"lint-staged": "^8.1.3",
Expand All @@ -106,7 +106,7 @@
"rollup": "3.25.1",
"sinon": "^7.2.3",
"tslint": "^6.1.3",
"typescript": "4.6.2",
"typescript": "^5.1.3",
"yargs": "^17.7.2"
},
"peerDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,12 @@
};
let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
const defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
const nodeAsString = nodesToString(children, reactI18nextOptions);
const defaultValue = defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
const {
hashTransKey
} = reactI18nextOptions;
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);
const interpolationOverride = values ? tOptions.interpolation : {
interpolation: {
...tOptions.interpolation,
Expand Down
2 changes: 1 addition & 1 deletion react-i18next.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/TransWithoutContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ export function Trans({
const defaultValue =
defaults || nodeAsString || reactI18nextOptions.transEmptyNodeValue || i18nKey;
const { hashTransKey } = reactI18nextOptions;
const key = i18nKey || (hashTransKey ? hashTransKey(nodeAsString) : nodeAsString);
const key =
i18nKey ||
(hashTransKey ? hashTransKey(nodeAsString || defaultValue) : nodeAsString || defaultValue);

This comment has been minimized.

Copy link
@nicegamer7

nicegamer7 Aug 23, 2023

Contributor

Good catch on this, I was about to open a PR lol. My apologies for letting this slip.

This comment has been minimized.

Copy link
@adrai

adrai Aug 23, 2023

Author Member

no problem ;-)

const interpolationOverride = values
? tOptions.interpolation
: { interpolation: { ...tOptions.interpolation, prefix: '#$?', suffix: '?$#' } };
Expand Down
105 changes: 54 additions & 51 deletions test/typescript/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,67 @@ import i18n from 'i18next';
//
// setI18n(i18n);

i18n.init({
lng: 'en',
fallbackLng: 'en',
i18n.init(
{
lng: 'en',
fallbackLng: 'en',

resources: {
en: {
translation: {
key1: 'test',
interpolateKey: 'add {{insert}} {{up, uppercase}}',
interpolateKey2: '<strong>add</strong> {{insert}} {{up, uppercase}}',
transTest1: 'Go <1>there</1>.',
transTest1_noParent: '<0>Go <1>there</1>.</0>',
transTest1_customHtml: '<strong>Go</strong> <br/><1>there</1>.',
transTest1_customHtml2: '<strong>Go</strong> <br/> there.',
transTest1_customHtml3:
'<strong>Go</strong><video /><script>console.warn("test")</script> there.',
transTest2:
'Hello <1><0>{{name}}</0></1>, you have <3>{{count}}</3> message. Open <5>hear</5>.',
transTest2_other:
'Hello <1><0>{{name}}</0></1>, you have <3>{{count}}</3> messages. Open <5>here</5>.',
transTest2InV2: 'Hello <1>{{name}}</1>, you have {{count}} message. Open <5>hear</5>.',
transTest2InV2_other:
'Hello <1>{{name}}</1>, you have {{count}} messages. Open <5>here</5>.',
testTransKey1: '<0>{{numOfItems}}</0> item matched.',
testTransKey1_other: '<0>{{numOfItems}}</0> items matched.',
testTransKey2: '<0><0>{{numOfItems}}</0></0> item matched.',
testTransKey2_other: '<0><0>{{numOfItems}}</0></0> items matched.',
testTransKey3: 'Result: <1><0>{{numOfItems}}</0></1> item matched.',
testTransKey3_other: 'Result: <1><0>{{numOfItems}}</0></1> items matched.',
testInvalidHtml: '<hello',
testInvalidHtml2: '<hello>',
testTrans4KeyWithNestedComponent: 'Result should be a list: <0></0>',
testTrans5KeyWithNestedComponent: 'Result should be a list: <1></1>',
testTrans5KeyWithValue: 'Result should be rendered within tag <0>{{testValue}}</0>',
deepPath: {
deepKey1: 'value1',
resources: {
en: {
translation: {
key1: 'test',
interpolateKey: 'add {{insert}} {{up, uppercase}}',
interpolateKey2: '<strong>add</strong> {{insert}} {{up, uppercase}}',
transTest1: 'Go <1>there</1>.',
transTest1_noParent: '<0>Go <1>there</1>.</0>',
transTest1_customHtml: '<strong>Go</strong> <br/><1>there</1>.',
transTest1_customHtml2: '<strong>Go</strong> <br/> there.',
transTest1_customHtml3:
'<strong>Go</strong><video /><script>console.warn("test")</script> there.',
transTest2:
'Hello <1><0>{{name}}</0></1>, you have <3>{{count}}</3> message. Open <5>hear</5>.',
transTest2_other:
'Hello <1><0>{{name}}</0></1>, you have <3>{{count}}</3> messages. Open <5>here</5>.',
transTest2InV2: 'Hello <1>{{name}}</1>, you have {{count}} message. Open <5>hear</5>.',
transTest2InV2_other:
'Hello <1>{{name}}</1>, you have {{count}} messages. Open <5>here</5>.',
testTransKey1: '<0>{{numOfItems}}</0> item matched.',
testTransKey1_other: '<0>{{numOfItems}}</0> items matched.',
testTransKey2: '<0><0>{{numOfItems}}</0></0> item matched.',
testTransKey2_other: '<0><0>{{numOfItems}}</0></0> items matched.',
testTransKey3: 'Result: <1><0>{{numOfItems}}</0></1> item matched.',
testTransKey3_other: 'Result: <1><0>{{numOfItems}}</0></1> items matched.',
testInvalidHtml: '<hello',
testInvalidHtml2: '<hello>',
testTrans4KeyWithNestedComponent: 'Result should be a list: <0></0>',
testTrans5KeyWithNestedComponent: 'Result should be a list: <1></1>',
testTrans5KeyWithValue: 'Result should be rendered within tag <0>{{testValue}}</0>',
deepPath: {
deepKey1: 'value1',
},
},
other: {
transTest1: 'Another go <1>there</1>.',
},
},
other: {
transTest1: 'Another go <1>there</1>.',
},
},
},

interpolation: {
escapeValue: false, // not needed for react!!
formatSeparator: ',',
format(value, format) {
if (format === 'uppercase') return value.toUpperCase();
return value;
interpolation: {
escapeValue: false, // not needed for react!!
formatSeparator: ',',
format(value: any, format?: string): string {
if (format === 'uppercase') return value.toUpperCase();
return value;
},
},
},

react: {
defaultTransParent: 'div',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
react: {
defaultTransParent: 'div',
transSupportBasicHtmlNodes: true,
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i'],
},
},
});
() => {},
);

export default i18n;

0 comments on commit a3a0bf0

Please sign in to comment.