diff --git a/.eslintrc.js b/.eslintrc.js
index 66b976c0..5ca4c325 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -25,6 +25,7 @@ module.exports = {
'node_modules',
'next.config.js',
'i18next-parser.config.js',
+ 'next-i18next.config.js',
'env-config.*',
'.*' ],
rules: {
diff --git a/components/blocks/RawContent.tsx b/components/blocks/RawContent.tsx
index 32292c7b..0a9eb937 100644
--- a/components/blocks/RawContent.tsx
+++ b/components/blocks/RawContent.tsx
@@ -2,7 +2,7 @@ import { Card } from '@components/elements/cards';
import { OverflowScroll } from '@components/elements/styled-divs';
import { Button } from '@components/elements/button';
import { useState } from 'react';
-import { useTranslation } from 'react-i18next';
+import { useTranslation } from 'next-i18next';
interface IRawContentProps {
content: unknown;
@@ -19,8 +19,8 @@ export const RawContent = ({ content, title }: IRawContentProps) => {
};
export const RawContentBtnLabel = () => {
- const { i18n } = useTranslation();
- return <>{i18n.t('components.raw_content.label')}>;
+ const { t } = useTranslation();
+ return <>{t('components.raw_content.label')}>;
};
export const RawContentBtn = (props: IRawContentProps) => {
diff --git a/components/blocks/copy-button.tsx b/components/blocks/copy-button.tsx
index c275a011..d590a9ca 100644
--- a/components/blocks/copy-button.tsx
+++ b/components/blocks/copy-button.tsx
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import copy from 'copy-to-clipboard';
-import { useTranslation } from 'react-i18next';
+import { useTranslation } from 'next-i18next';
import { IoCopy } from 'react-icons/io5';
import { IconContext } from 'react-icons';
import styled from 'styled-components';
@@ -20,8 +20,7 @@ export const CopyButton = ({
color?: string;
copyMessage?: string;
}) => {
- const { i18n } = useTranslation();
-
+ const { t } = useTranslation();
const { setCopiedMessage, message } = useCopiedMessage();
const handleCopy = (e) => {
e.cancelBubble = true;
@@ -29,7 +28,7 @@ export const CopyButton = ({
e.preventDefault();
e.target.focus();
copy(toCopy);
- setCopiedMessage(copyMessage ?? i18n.t('copy.copied_to_the_clipboard'));
+ setCopiedMessage(copyMessage ?? t('copy.copied_to_the_clipboard'));
};
return (
diff --git a/components/blocks/error.tsx b/components/blocks/error.tsx
index d212ad24..578f4a66 100644
--- a/components/blocks/error.tsx
+++ b/components/blocks/error.tsx
@@ -1,7 +1,8 @@
-import i18n from '../../i18n';
+import { useTranslation } from 'next-i18next';
-const ErrorPage = (props: { message?: string }) => (
-
{(props && props.message) || i18n.t('errors.general_error')}
-);
+const ErrorPage = (props: { message?: string }) => {
+ const { t } = useTranslation();
+ return {(props && props.message) || t('errors.general_error')}
;
+};
export default ErrorPage;
diff --git a/components/blocks/language-selector.tsx b/components/blocks/language-selector.tsx
index 93923a15..e21eb082 100644
--- a/components/blocks/language-selector.tsx
+++ b/components/blocks/language-selector.tsx
@@ -1,8 +1,7 @@
-import { useTranslation } from 'react-i18next';
import { IconButton, Menu, MenuButton, MenuItem, MenuList } from '@chakra-ui/react';
-import { useCallback, useEffect, useMemo } from 'react';
+import { useCallback } from 'react';
import { HiLanguage } from 'react-icons/hi2';
-import LanguageDetector from 'i18next-browser-languagedetector';
+import router from 'next/router';
type LanguageOption = {
code: string;
@@ -16,23 +15,10 @@ const languages: LanguageOption[] = [
];
const LanguageSelector = ({ bg = 'transparent', size, color }: { bg?: string; size?: string; color?: string }) => {
- const { i18n } = useTranslation();
-
- const languageDetector = useMemo(() => new LanguageDetector(), []);
-
- useEffect(() => {
- languageDetector.init();
- const lng = languageDetector.detect();
- i18n.changeLanguage(typeof lng === 'string' ? lng : lng[0]);
- }, [i18n, languageDetector]);
-
- const handleLanguageChange = useCallback(
- (languageCode: string) => {
- i18n.changeLanguage(languageCode);
- languageDetector.cacheUserLanguage(languageCode);
- },
- [i18n, languageDetector]
- );
+ const handleLanguageChange = useCallback((languageCode: string) => {
+ const { pathname, query } = router;
+ router.push({ pathname, query }, router.asPath, { locale: languageCode });
+ }, []);
return (