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: v12.1.1
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: v12.1.2
Choose a head ref
  • 6 commits
  • 17 files changed
  • 1 contributor

Commits on Dec 7, 2022

  1. update some examples

    adrai committed Dec 7, 2022
    Copy the full SHA
    0d5bd6e View commit details

Commits on Dec 12, 2022

  1. update tests

    adrai committed Dec 12, 2022
    Copy the full SHA
    3dd9aa8 View commit details
  2. update deps for ts

    adrai committed Dec 12, 2022
    Copy the full SHA
    bbe4d52 View commit details

Commits on Dec 22, 2022

  1. Copy the full SHA
    98b118b View commit details

Commits on Jan 7, 2023

  1. fix crash in gatsby

    adrai committed Jan 7, 2023
    Copy the full SHA
    187f7bf View commit details
  2. 12.1.2

    adrai committed Jan 7, 2023
    Copy the full SHA
    c997603 View commit details
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 12.1.2

- fix crash in gatsby [1594](https://github.com/i18next/react-i18next/issues/1594)

### 12.1.1

- fix for node resolution [1589](https://github.com/i18next/react-i18next/issues/1589)
37,827 changes: 24,735 additions & 13,092 deletions example/locize/package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions example/locize/package.json
Original file line number Diff line number Diff line change
@@ -3,15 +3,15 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"i18next": "21.0.0",
"i18next-browser-languagedetector": "6.1.1",
"i18next-locize-backend": "4.2.2",
"locize": "2.2.4",
"locize-lastused": "3.0.12",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-i18next": "11.10.0",
"react-scripts": "^4.0.3"
"i18next": "22.1.2",
"i18next-browser-languagedetector": "7.0.1",
"i18next-locize-backend": "6.0.1",
"locize": "2.4.5",
"locize-lastused": "3.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "12.1.1",
"react-scripts": "5.0.1"
},
"scripts": {
"start": "react-scripts start",
5 changes: 3 additions & 2 deletions example/locize/src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import './index.css';
import App from './App';

// import i18n (needs to be bundled ;))
import './i18n';

ReactDOM.render(<App />, document.getElementById('root'));
const root = createRoot(document.getElementById('root'));
root.render(<App />);
10 changes: 5 additions & 5 deletions example/react-typescript/simple-multi-namespaces/package.json
Original file line number Diff line number Diff line change
@@ -3,16 +3,16 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"i18next": "^22.0.4",
"i18next": "^22.4.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^12.0.0"
"react-i18next": "^12.1.1"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"react-scripts": "5.0.1",
"typescript": "^4.8.4"
"typescript": "^4.9.4"
},
"scripts": {
"start": "react-scripts start",
10 changes: 5 additions & 5 deletions example/react-typescript/simple/package.json
Original file line number Diff line number Diff line change
@@ -3,16 +3,16 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"i18next": "^22.0.4",
"i18next": "^22.4.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^12.0.0"
"react-i18next": "^12.1.1"
},
"devDependencies": {
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"react-scripts": "5.0.1",
"typescript": "^4.8.4"
"typescript": "^4.9.4"
},
"scripts": {
"start": "react-scripts start",
4 changes: 2 additions & 2 deletions example/react-typescript/simple/src/App.tsx
Original file line number Diff line number Diff line change
@@ -2,11 +2,11 @@ import './i18n/config';
import { useTranslation } from 'react-i18next';

function App() {
const {t} = useTranslation();
const { t } = useTranslation();

return (
<div className="App">
<p>{t('title')}</p>
<p>{t('title', { name: 'John' })}</p>
<p>{t('description.part1')}</p>
<p>{t('description.part2')}</p>
</div>
4 changes: 2 additions & 2 deletions example/react-typescript/simple/src/i18n/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Welcome to react using react-i18next fully type-safe",
"title": "Welcome {{name}}, to react using react-i18next fully type-safe",
"description": {
"part1": "This is a simple example.",
"part2": "😉"
}
}
}
9,885 changes: 5,385 additions & 4,500 deletions example/react/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions example/react/package.json
Original file line number Diff line number Diff line change
@@ -3,12 +3,12 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"i18next": "21.6.16",
"i18next-browser-languagedetector": "6.1.4",
"i18next-http-backend": "1.4.0",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-i18next": "11.16.7",
"i18next": "22.1.2",
"i18next-browser-languagedetector": "7.0.1",
"i18next-http-backend": "2.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "12.1.1",
"react-scripts": "5.0.1"
},
"scripts": {
52 changes: 26 additions & 26 deletions package-lock.json
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-i18next",
"version": "12.1.1",
"version": "12.1.2",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "./index.d.ts",
@@ -42,7 +42,7 @@
"url": "https://github.com/i18next/react-i18next.git"
},
"dependencies": {
"@babel/runtime": "^7.14.5",
"@babel/runtime": "^7.20.6",
"html-parse-stringify": "^3.0.1"
},
"devDependencies": {
@@ -78,7 +78,7 @@
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-testing-library": "^3.10.1",
"husky": "^3.0.3",
"i18next": "^22.0.1",
"i18next": "^22.4.3",
"jest": "^24.8.0",
"jest-cli": "^24.8.4",
"lint-staged": "^8.1.3",
4 changes: 2 additions & 2 deletions react-i18next.js
Original file line number Diff line number Diff line change
@@ -808,7 +808,7 @@

var i18n = i18nFromProps || i18nFromContext || getI18n();

var t = tFromProps || i18n.t.bind(i18n) || function (k) {
var t = tFromProps || i18n && i18n.t.bind(i18n) || function (k) {
return k;
};

@@ -822,7 +822,7 @@
values: values,
defaults: defaults,
components: components,
ns: ns || t.ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS,
ns: ns || t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
i18n: i18n,
t: tFromProps,
shouldUnescape: shouldUnescape
2 changes: 1 addition & 1 deletion react-i18next.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Trans.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ export function Trans({
const { i18n: i18nFromContext, defaultNS: defaultNSFromContext } = useContext(I18nContext) || {};
const i18n = i18nFromProps || i18nFromContext || getI18n();

const t = tFromProps || i18n.t.bind(i18n) || ((k) => k);
const t = tFromProps || (i18n && i18n.t.bind(i18n)) || ((k) => k);

return TransWithoutContext({
children,
@@ -36,7 +36,7 @@ export function Trans({
defaults,
components,
// prepare having a namespace
ns: ns || t.ns || defaultNSFromContext || (i18n.options && i18n.options.defaultNS),
ns: ns || t.ns || defaultNSFromContext || (i18n && i18n.options && i18n.options.defaultNS),
i18n,
t: tFromProps,
shouldUnescape,
5 changes: 0 additions & 5 deletions test/typescript/custom-types/Translation.test.tsx
Original file line number Diff line number Diff line change
@@ -36,11 +36,6 @@ function expectErrorWhenKeyNotInNamespace() {
return <Translation ns="custom">{(t) => <>{t('fake')}</>}</Translation>;
}

function expectErrorWhenUsingArrayNamespaceAndUnscopedKey() {
// @ts-expect-error
return <Translation ns={['custom']}>{(t) => <>{t('foo')}</>}</Translation>;
}

function expectErrorWhenUsingArrayNamespaceAndWrongKey() {
// @ts-expect-error
return <Translation ns={['custom']}>{(t) => <>{t('custom:fake')}</>}</Translation>;
16 changes: 8 additions & 8 deletions test/typescript/custom-types/useTranslation.test.tsx
Original file line number Diff line number Diff line change
@@ -22,7 +22,9 @@ function arrayNamespace() {
return (
<>
{t('alternate:baz')}
{t('baz', { ns: 'alternate' })}
{t('custom:foo')}
{t('foo', { ns: 'custom' })}
</>
);
}
@@ -33,7 +35,9 @@ function readonlyArrayNamespace() {
return (
<>
{t('alternate:baz')}
{t('baz', { ns: 'alternate' })}
{t('custom:foo')}
{t('foo', { ns: 'custom' })}
</>
);
}
@@ -47,7 +51,7 @@ function deepKeyPrefixOption() {
const [t] = useTranslation('alternate', { keyPrefix: 'foobar.deep' });
return (
<>
{t('deeper').deeeeeper}
{t('deeper', { returnObjects: true }).deeeeeper}
{t('deeper.deeeeeper')}
</>
);
@@ -75,16 +79,12 @@ function expectErrorWhenKeyNotInNamespace() {
return <>{t('fake')}</>;
}

function expectErrorWhenUsingArrayNamespaceAndUnscopedKey() {
const [t] = useTranslation(['custom']);
// @ts-expect-error
return <>{t('foo')}</>;
}

function expectErrorWhenUsingArrayNamespaceAndWrongKey() {
const [t] = useTranslation(['custom']);
// @ts-expect-error
return <>{t('custom:fake')}</>;
<>{t('custom:fake')}</>;
// @ts-expect-error
return <>{t('fake', { ns: 'custom' })}</>;
}

function expectErrorWhenUsingWrongKeyPrefixOption() {