From a09cda3395ca1dffe2190741c4b7e3842bf3feee Mon Sep 17 00:00:00 2001 From: Ilko Kacharov Date: Tue, 2 Mar 2021 18:49:26 +0200 Subject: [PATCH] Replace react-i18next imports with next-i18next --- CONTRIBUTING.md | 4 ++-- package.json | 1 - src/common/form/README.md | 2 +- src/common/form/validation.ts | 2 +- src/components/about/AboutPage.tsx | 2 +- src/components/auth/changePassword/ChangePasswordPage.tsx | 2 +- .../auth/forgottenPassword/ForgottenPasswordForm.tsx | 2 +- .../auth/forgottenPassword/ForgottenPasswordPage.tsx | 2 +- src/components/auth/login/LoginForm.tsx | 2 +- src/components/auth/login/LoginPage.tsx | 2 +- src/components/auth/profile/ProfilePage.tsx | 2 +- src/components/auth/register/RegisterPage.tsx | 2 +- src/components/common/form/FormTextField.tsx | 2 +- src/components/common/form/SubmitButton.tsx | 2 +- src/components/index/helpers/Typewriter.tsx | 2 +- src/components/index/helpers/chart/TeamPie.tsx | 2 +- src/components/index/sections/ActivitySection.tsx | 2 +- src/components/index/sections/Jumbotron.tsx | 2 +- src/components/index/sections/ProblemsToSolveSection.tsx | 2 +- src/components/index/sections/SupportUsSection.tsx | 2 +- src/components/index/sections/TeamChartSection.tsx | 2 +- src/components/index/sections/TeamSection.tsx | 2 +- src/components/layout/LocaleButton.tsx | 2 +- src/components/layout/LocaleMenu.tsx | 2 +- src/components/layout/LocaleSwitcher.tsx | 2 +- src/components/layout/nav/MainNavMenu.tsx | 2 +- src/components/layout/nav/MobileNav.tsx | 2 +- src/components/layout/nav/PrivateMenu.tsx | 2 +- src/components/layout/nav/PublicMenu.tsx | 2 +- src/components/support-form/Actions.tsx | 2 +- src/components/support-form/SupportPage.tsx | 2 +- src/components/support-form/steps/AdditionalQuestions.tsx | 2 +- src/components/support-form/steps/GeneralInfo.tsx | 2 +- src/components/support-form/steps/Newsletter.tsx | 2 +- src/components/support-form/steps/Roles.tsx | 2 +- src/components/support-form/steps/ThankYou.tsx | 2 +- 36 files changed, 36 insertions(+), 37 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0f3e4cecb..36d47b9af 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -127,7 +127,7 @@ A common way to sort the imports in the file is by their source: `external`, `ab ```tsx import React, { useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import Nav from 'components/layout/Nav' import Layout from 'components/layout/Layout' @@ -418,7 +418,7 @@ Usage of translation hook `useTranslation` is preferred over usage of ` #### Usage in components ```tsx -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' export default function CustomComponent() { const { t } = useTranslation() diff --git a/package.json b/package.json index 74c339312..1191c5a5a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "formik": "^2.2.6", "highcharts": "^9.0.1", "highcharts-react-official": "^3.0.0", - "i18next": "^19.8.4", "mobx": "^6.0.4", "mobx-react": "^7.0.5", "next": "^10.0.5", diff --git a/src/common/form/README.md b/src/common/form/README.md index 375dbd672..7deda95d2 100644 --- a/src/common/form/README.md +++ b/src/common/form/README.md @@ -5,7 +5,7 @@ ```tsx import React from 'react' import * as yup from 'yup' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Grid, TextField, Button } from '@material-ui/core' import { AlertStore } from 'stores/AlertStore' diff --git a/src/common/form/validation.ts b/src/common/form/validation.ts index c97c1944c..bee076d97 100644 --- a/src/common/form/validation.ts +++ b/src/common/form/validation.ts @@ -1,6 +1,6 @@ import { setLocale } from 'yup' import { TOptions } from 'i18next' -import { TFunction } from 'react-i18next' +import { TFunction } from 'next-i18next' export type TranslatableField = (string | undefined) | { key: string; values?: TOptions } diff --git a/src/components/about/AboutPage.tsx b/src/components/about/AboutPage.tsx index e73411529..6814658f6 100644 --- a/src/components/about/AboutPage.tsx +++ b/src/components/about/AboutPage.tsx @@ -1,6 +1,6 @@ import { Typography } from '@material-ui/core' import Layout from 'components/layout/Layout' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import styles from './about.module.scss' diff --git a/src/components/auth/changePassword/ChangePasswordPage.tsx b/src/components/auth/changePassword/ChangePasswordPage.tsx index 51bde6bd2..ca737ba71 100644 --- a/src/components/auth/changePassword/ChangePasswordPage.tsx +++ b/src/components/auth/changePassword/ChangePasswordPage.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Container } from '@material-ui/core' import Layout from 'components/layout/Layout' diff --git a/src/components/auth/forgottenPassword/ForgottenPasswordForm.tsx b/src/components/auth/forgottenPassword/ForgottenPasswordForm.tsx index 5e56d0a83..8d5e20414 100644 --- a/src/components/auth/forgottenPassword/ForgottenPasswordForm.tsx +++ b/src/components/auth/forgottenPassword/ForgottenPasswordForm.tsx @@ -1,6 +1,6 @@ import React from 'react' import * as yup from 'yup' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Typography, Grid } from '@material-ui/core' import SubmitButton from 'components/common/form/SubmitButton' diff --git a/src/components/auth/forgottenPassword/ForgottenPasswordPage.tsx b/src/components/auth/forgottenPassword/ForgottenPasswordPage.tsx index d93f968a8..7e803733c 100644 --- a/src/components/auth/forgottenPassword/ForgottenPasswordPage.tsx +++ b/src/components/auth/forgottenPassword/ForgottenPasswordPage.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Container } from '@material-ui/core' import Layout from 'components/layout/Layout' diff --git a/src/components/auth/login/LoginForm.tsx b/src/components/auth/login/LoginForm.tsx index 06c5cb4b3..2c9ce4b75 100644 --- a/src/components/auth/login/LoginForm.tsx +++ b/src/components/auth/login/LoginForm.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react' import * as yup from 'yup' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Grid } from '@material-ui/core' import { AlertStore } from 'stores/AlertStore' diff --git a/src/components/auth/login/LoginPage.tsx b/src/components/auth/login/LoginPage.tsx index 955be8d11..2ee4c0935 100644 --- a/src/components/auth/login/LoginPage.tsx +++ b/src/components/auth/login/LoginPage.tsx @@ -1,6 +1,6 @@ import React from 'react' import { signIn } from 'next-auth/client' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Container, Grid, Box, Button } from '@material-ui/core' import Link from 'components/common/Link' diff --git a/src/components/auth/profile/ProfilePage.tsx b/src/components/auth/profile/ProfilePage.tsx index e03ac2385..3486a3905 100644 --- a/src/components/auth/profile/ProfilePage.tsx +++ b/src/components/auth/profile/ProfilePage.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Avatar, Box, diff --git a/src/components/auth/register/RegisterPage.tsx b/src/components/auth/register/RegisterPage.tsx index f4110d255..93435776c 100644 --- a/src/components/auth/register/RegisterPage.tsx +++ b/src/components/auth/register/RegisterPage.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Container } from '@material-ui/core' import Layout from 'components/layout/Layout' diff --git a/src/components/common/form/FormTextField.tsx b/src/components/common/form/FormTextField.tsx index 008649332..be4bda6fc 100644 --- a/src/components/common/form/FormTextField.tsx +++ b/src/components/common/form/FormTextField.tsx @@ -1,7 +1,7 @@ import React from 'react' import { FormikValues } from 'formik' import { TextField, TextFieldProps } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { translateError } from 'common/form/useForm' import { TranslatableField } from 'common/form/validation' diff --git a/src/components/common/form/SubmitButton.tsx b/src/components/common/form/SubmitButton.tsx index b7675674b..d1d1e68cf 100644 --- a/src/components/common/form/SubmitButton.tsx +++ b/src/components/common/form/SubmitButton.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles, Theme } from '@material-ui/core/styles' import { Button, ButtonProps, CircularProgress, CircularProgressProps } from '@material-ui/core' diff --git a/src/components/index/helpers/Typewriter.tsx b/src/components/index/helpers/Typewriter.tsx index 465163020..01db97837 100644 --- a/src/components/index/helpers/Typewriter.tsx +++ b/src/components/index/helpers/Typewriter.tsx @@ -1,5 +1,5 @@ import Typewriter from 'typewriter-effect' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Typography } from '@material-ui/core' import { makeStyles, createStyles } from '@material-ui/core/styles' diff --git a/src/components/index/helpers/chart/TeamPie.tsx b/src/components/index/helpers/chart/TeamPie.tsx index bb1cb37ca..1d29ae042 100644 --- a/src/components/index/helpers/chart/TeamPie.tsx +++ b/src/components/index/helpers/chart/TeamPie.tsx @@ -2,7 +2,7 @@ import React from 'react' import Highcharts from 'highcharts' import HighchartsReact from 'highcharts-react-official' import { teamPieData, teamPieOptions, TeamPieItem } from 'components/index/helpers/chart/pieData' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import handleViewport from 'react-in-viewport' export type TeamPieProps = { diff --git a/src/components/index/sections/ActivitySection.tsx b/src/components/index/sections/ActivitySection.tsx index ec9deb42f..55cdf1150 100644 --- a/src/components/index/sections/ActivitySection.tsx +++ b/src/components/index/sections/ActivitySection.tsx @@ -1,5 +1,5 @@ import { Grid, Typography } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles } from '@material-ui/core/styles' const useStyles = makeStyles((theme) => diff --git a/src/components/index/sections/Jumbotron.tsx b/src/components/index/sections/Jumbotron.tsx index df0a47814..66793d4b4 100644 --- a/src/components/index/sections/Jumbotron.tsx +++ b/src/components/index/sections/Jumbotron.tsx @@ -1,4 +1,4 @@ -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Grid, Typography } from '@material-ui/core' import { makeStyles, createStyles } from '@material-ui/core/styles' diff --git a/src/components/index/sections/ProblemsToSolveSection.tsx b/src/components/index/sections/ProblemsToSolveSection.tsx index ba3680809..e031c1033 100644 --- a/src/components/index/sections/ProblemsToSolveSection.tsx +++ b/src/components/index/sections/ProblemsToSolveSection.tsx @@ -1,5 +1,5 @@ import { Grid, Typography } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles } from '@material-ui/core/styles' import CommissionsIcon from '../icons/problems-to-solve-icons/CommissionsIcon' diff --git a/src/components/index/sections/SupportUsSection.tsx b/src/components/index/sections/SupportUsSection.tsx index 18aaa5acb..dfc8bfd05 100644 --- a/src/components/index/sections/SupportUsSection.tsx +++ b/src/components/index/sections/SupportUsSection.tsx @@ -1,5 +1,5 @@ import { Grid, Typography } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles } from '@material-ui/core/styles' import FinancesIcon from '../icons/support-us-icons/FinancesIcon' diff --git a/src/components/index/sections/TeamChartSection.tsx b/src/components/index/sections/TeamChartSection.tsx index 8fbf6c3e0..3a59fa091 100644 --- a/src/components/index/sections/TeamChartSection.tsx +++ b/src/components/index/sections/TeamChartSection.tsx @@ -1,5 +1,5 @@ import { Grid, Typography, Box } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles } from '@material-ui/core/styles' import TeamPie from 'components/index/helpers/chart/TeamPie' diff --git a/src/components/index/sections/TeamSection.tsx b/src/components/index/sections/TeamSection.tsx index b47f095b6..7663afbd6 100644 --- a/src/components/index/sections/TeamSection.tsx +++ b/src/components/index/sections/TeamSection.tsx @@ -1,5 +1,5 @@ import { Grid, Typography } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles } from '@material-ui/core/styles' const useStyles = makeStyles((theme) => diff --git a/src/components/layout/LocaleButton.tsx b/src/components/layout/LocaleButton.tsx index 7c4e6e8b7..a8b8b4f9e 100644 --- a/src/components/layout/LocaleButton.tsx +++ b/src/components/layout/LocaleButton.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react' import { useRouter } from 'next/router' import { Button } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' export default function LocaleMenu() { const router = useRouter() diff --git a/src/components/layout/LocaleMenu.tsx b/src/components/layout/LocaleMenu.tsx index 1c5fd71a1..22552a075 100644 --- a/src/components/layout/LocaleMenu.tsx +++ b/src/components/layout/LocaleMenu.tsx @@ -1,6 +1,6 @@ import { useRouter } from 'next/router' import { useCallback, useState } from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Button, Menu, MenuItem } from '@material-ui/core' export default function LocaleMenu() { diff --git a/src/components/layout/LocaleSwitcher.tsx b/src/components/layout/LocaleSwitcher.tsx index 281ab1301..5c2449ce4 100644 --- a/src/components/layout/LocaleSwitcher.tsx +++ b/src/components/layout/LocaleSwitcher.tsx @@ -1,6 +1,6 @@ import { useCallback } from 'react' import { useRouter } from 'next/router' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Box, Button, ButtonGroup } from '@material-ui/core' export default function LocaleSwitcher() { diff --git a/src/components/layout/nav/MainNavMenu.tsx b/src/components/layout/nav/MainNavMenu.tsx index 66140a91e..97ab8e4d0 100644 --- a/src/components/layout/nav/MainNavMenu.tsx +++ b/src/components/layout/nav/MainNavMenu.tsx @@ -1,6 +1,6 @@ import React from 'react' import { Grid } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { routes } from 'common/routes' import LinkButton from 'components/common/LinkButton' diff --git a/src/components/layout/nav/MobileNav.tsx b/src/components/layout/nav/MobileNav.tsx index 7f58a247f..c9af9b719 100644 --- a/src/components/layout/nav/MobileNav.tsx +++ b/src/components/layout/nav/MobileNav.tsx @@ -1,7 +1,7 @@ import { useRouter } from 'next/router' import React, { useEffect } from 'react' import { useSession } from 'next-auth/client' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { makeStyles, createStyles } from '@material-ui/core/styles' import { SwipeableDrawer, Hidden, Box, Grid } from '@material-ui/core' diff --git a/src/components/layout/nav/PrivateMenu.tsx b/src/components/layout/nav/PrivateMenu.tsx index b2b93583b..2c54d3c03 100644 --- a/src/components/layout/nav/PrivateMenu.tsx +++ b/src/components/layout/nav/PrivateMenu.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react' import { useRouter } from 'next/router' import { useSession } from 'next-auth/client' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { AccountCircle } from '@material-ui/icons' import { Avatar, Grid, IconButton, Menu, MenuItem } from '@material-ui/core' diff --git a/src/components/layout/nav/PublicMenu.tsx b/src/components/layout/nav/PublicMenu.tsx index c740276d4..233a6a779 100644 --- a/src/components/layout/nav/PublicMenu.tsx +++ b/src/components/layout/nav/PublicMenu.tsx @@ -1,6 +1,6 @@ import React from 'react' import { Grid } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { routes } from 'common/routes' import LinkButton from 'components/common/LinkButton' diff --git a/src/components/support-form/Actions.tsx b/src/components/support-form/Actions.tsx index bde96e9f5..24b0102e5 100644 --- a/src/components/support-form/Actions.tsx +++ b/src/components/support-form/Actions.tsx @@ -1,6 +1,6 @@ import { MouseEvent } from 'react' import { Button, Grid } from '@material-ui/core' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' type ActionsProps = { nextLabel: string diff --git a/src/components/support-form/SupportPage.tsx b/src/components/support-form/SupportPage.tsx index e71aaab7c..f472abd6d 100644 --- a/src/components/support-form/SupportPage.tsx +++ b/src/components/support-form/SupportPage.tsx @@ -1,5 +1,5 @@ import { FormikErrors } from 'formik' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import React, { useEffect, useState } from 'react' import { makeStyles, Theme, createStyles, withStyles } from '@material-ui/core/styles' import { Container, Stepper, Step, StepLabel, StepConnector, Hidden, Grid } from '@material-ui/core' diff --git a/src/components/support-form/steps/AdditionalQuestions.tsx b/src/components/support-form/steps/AdditionalQuestions.tsx index 27ea71068..c4cb14d89 100644 --- a/src/components/support-form/steps/AdditionalQuestions.tsx +++ b/src/components/support-form/steps/AdditionalQuestions.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { FormikProps } from 'formik' import { Checkbox, diff --git a/src/components/support-form/steps/GeneralInfo.tsx b/src/components/support-form/steps/GeneralInfo.tsx index 618433518..8608b09a4 100644 --- a/src/components/support-form/steps/GeneralInfo.tsx +++ b/src/components/support-form/steps/GeneralInfo.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Checkbox, FormControl, diff --git a/src/components/support-form/steps/Newsletter.tsx b/src/components/support-form/steps/Newsletter.tsx index 3b51b8751..ade695ea5 100644 --- a/src/components/support-form/steps/Newsletter.tsx +++ b/src/components/support-form/steps/Newsletter.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { FormikProps } from 'formik' import { Checkbox, FormControl, FormControlLabel, FormLabel } from '@material-ui/core' diff --git a/src/components/support-form/steps/Roles.tsx b/src/components/support-form/steps/Roles.tsx index 2d4f18d23..a102ce226 100644 --- a/src/components/support-form/steps/Roles.tsx +++ b/src/components/support-form/steps/Roles.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { Checkbox, FormControl, diff --git a/src/components/support-form/steps/ThankYou.tsx b/src/components/support-form/steps/ThankYou.tsx index 9deb75214..473908ce6 100644 --- a/src/components/support-form/steps/ThankYou.tsx +++ b/src/components/support-form/steps/ThankYou.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { useTranslation } from 'react-i18next' +import { useTranslation } from 'next-i18next' import { createStyles, Grid, makeStyles, Theme, Typography } from '@material-ui/core' const useStyles = makeStyles((theme: Theme) =>