Skip to content

Commit 2c06c58

Browse files
committed
Feature(translation): upgrade react-i18next to v10
1 parent 8368060 commit 2c06c58

File tree

17 files changed

+105
-120
lines changed

17 files changed

+105
-120
lines changed

__mocks__/react-i18next.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const NamespacesConsumer = ({ children }: any) => children((k: string) => k, { i18n: {} });
1+
export const Translation = ({ children }: any) => children((k: string) => k, { i18n: {} });

frontend/src/components/Dropdown/dropdown.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33
import { Link } from 'react-router-dom';
44

55
interface IDropdownProps {
@@ -19,15 +19,15 @@ export class Dropdown extends React.Component<IDropdownProps> {
1919

2020
public render() {
2121
return (
22-
<NamespacesConsumer ns='common'>
22+
<Translation ns='common'>
2323
{(t) => (
2424
<ul id={this.props.id} className='dropdown-content'>
2525
{this.props.dropdownLists.map((key) =>
2626
<li key={key}><Link to={`/${key}`}>{t('dropdown.' + key)}</Link></li>,
2727
)}
2828
</ul>
2929
)}
30-
</NamespacesConsumer>
30+
</Translation>
3131
);
3232
}
3333
}

frontend/src/components/Footer/footer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33

44
export class Footer extends React.Component {
55
public render() {
66
return (
7-
<NamespacesConsumer ns='common'>
7+
<Translation ns='common'>
88
{(t) => (
99
<footer className='page-footer'>
1010
<div className='container'>
@@ -32,7 +32,7 @@ export class Footer extends React.Component {
3232
</div>
3333
</footer>
3434
)}
35-
</NamespacesConsumer>
35+
</Translation>
3636
);
3737
}
3838
}

frontend/src/components/Header/header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33
import { connect } from 'react-redux';
44
import { Link } from 'react-router-dom';
55

@@ -37,7 +37,7 @@ export class Header extends React.Component<IHeaderStateProps> {
3737
public render() {
3838
const dropdownList = ['parallax'];
3939
return (
40-
<NamespacesConsumer ns='common'>
40+
<Translation ns='common'>
4141
{(t) => (
4242
<div>
4343
<nav>
@@ -68,7 +68,7 @@ export class Header extends React.Component<IHeaderStateProps> {
6868
</ul>
6969
</div>
7070
)}
71-
</NamespacesConsumer>
71+
</Translation>
7272
);
7373
}
7474
}

frontend/src/pages/HomePage/components/Carousel/carousel.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33

44
import { CAROUSEL_AUTOPLAY_INTERVAL, TOAST_DISPLAY_DURATION, TOOLTIP_DELAY_TIME } from './constants/carousel';
55

@@ -55,7 +55,7 @@ export class Carousel extends React.Component {
5555

5656
public render() {
5757
return (
58-
<NamespacesConsumer ns='homePage'>
58+
<Translation ns='homePage'>
5959
{(t) => (
6060
this.initTooltip(t('carousel.tooltipText')),
6161
<div className='carousel carousel-slider center z-depth-3' data-indicators='true'>
@@ -82,7 +82,7 @@ export class Carousel extends React.Component {
8282
</a>
8383
</div>
8484
)}
85-
</NamespacesConsumer>
85+
</Translation>
8686
);
8787
}
8888
}

frontend/src/pages/HomePage/components/Pushpin/pushpin.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33

44
const styles = require('./pushpin.scss');
55

@@ -11,7 +11,7 @@ interface IPushpinProps {
1111
export class Pushpin extends React.Component<IPushpinProps> {
1212
public render() {
1313
return (
14-
<NamespacesConsumer ns='homePage'>
14+
<Translation ns='homePage'>
1515
{(t) => (
1616
<div id={this.props.color} className={`${styles.pushpin} ${this.props.color} ${this.props.depth}`}>
1717
<nav className='pushpin-nav pin-top' data-target={'pushpin-' + this.props.color}>
@@ -27,7 +27,7 @@ export class Pushpin extends React.Component<IPushpinProps> {
2727
</nav>
2828
</div>
2929
)}
30-
</NamespacesConsumer>
30+
</Translation>
3131
);
3232
}
3333
}

frontend/src/pages/HomePage/components/TranslationButton/translationButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import i18next from 'i18next';
22
import React from 'react';
3-
import { NamespacesConsumer } from 'react-i18next';
3+
import { Translation } from 'react-i18next';
44

55
const floatingActionButtonConfig: Partial<M.FloatingActionButtonOptions> = {
66
direction: 'top',
@@ -19,7 +19,7 @@ export class TranslationButton extends React.Component {
1919

2020
public render() {
2121
return (
22-
<NamespacesConsumer>
22+
<Translation>
2323
{(_, {i18n}) => (
2424
<div className='fixed-action-btn vertical'>
2525
<a className='btn-floating btn-large red'>
@@ -32,7 +32,7 @@ export class TranslationButton extends React.Component {
3232
</ul>
3333
</div>
3434
)}
35-
</NamespacesConsumer>
35+
</Translation>
3636
);
3737
}
3838
}

frontend/src/pages/HomePage/homePage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33

44
import Carousel from './components/Carousel';
55
import Pushpin from './components/Pushpin';
@@ -27,7 +27,7 @@ export class HomePage extends React.Component {
2727

2828
public render() {
2929
return (
30-
<NamespacesConsumer ns='homePage'>
30+
<Translation ns='homePage'>
3131
{(t) => (
3232
<div>
3333
<div className={styles['home-page-block']}>
@@ -45,7 +45,7 @@ export class HomePage extends React.Component {
4545
<TranslationButton />
4646
</div>
4747
)}
48-
</NamespacesConsumer>
48+
</Translation>
4949
);
5050
}
5151
}

frontend/src/pages/NotFoundPage/notFoundPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33

44
const styles = require('./notFoundPage.scss');
55

@@ -28,14 +28,14 @@ export class NotFoundPage extends React.Component<{}, INotFoundPageState> {
2828

2929
public render() {
3030
return (
31-
<NamespacesConsumer ns='notFoundPage'>
31+
<Translation ns='notFoundPage'>
3232
{(t) => (
3333
<div>
3434
<h1 className='page-title'>{t('title')}</h1>
3535
<img className={styles['not-found-img']} src={require('./assets/images/' + notFoundImageList[this.state.imageId])} alt='not-found-img' height='550px' width='750px' />
3636
</div>
3737
)}
38-
</NamespacesConsumer>
38+
</Translation>
3939
);
4040
}
4141
}

frontend/src/pages/ParallaxPage/parallaxPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { NamespacesConsumer } from 'react-i18next';
2+
import { Translation } from 'react-i18next';
33

44
import PrismCodes, { PARALLAX_CODE } from './components/PrismCodes';
55

@@ -13,7 +13,7 @@ export class ParallaxPage extends React.Component {
1313

1414
public render() {
1515
return (
16-
<NamespacesConsumer ns='parallaxPage'>
16+
<Translation ns='parallaxPage'>
1717
{(t) => (
1818
<div>
1919
<div className='white'>
@@ -43,7 +43,7 @@ export class ParallaxPage extends React.Component {
4343
</div>
4444
</div>
4545
)}
46-
</NamespacesConsumer>
46+
</Translation>
4747
);
4848
}
4949
}

0 commit comments

Comments
 (0)