diff --git a/next-i18next.config.js b/next-i18next.config.js index 00198802510..b80c946f58c 100644 --- a/next-i18next.config.js +++ b/next-i18next.config.js @@ -1,6 +1,6 @@ module.exports = { i18n: { - locales: ['en', 'ru'], + locales: ['en' /*, 'ru'*/], defaultLocale: 'en', defaultNS: 'common', ignoreJSONStructure: false, diff --git a/src/pages/[locale]/components/[libId]/[componentId].tsx b/src/[locale]/components/[libId]/[componentId].tsx similarity index 88% rename from src/pages/[locale]/components/[libId]/[componentId].tsx rename to src/[locale]/components/[libId]/[componentId].tsx index a3ed60cb65f..0362a471853 100644 --- a/src/pages/[locale]/components/[libId]/[componentId].tsx +++ b/src/[locale]/components/[libId]/[componentId].tsx @@ -2,13 +2,13 @@ import {GetStaticPaths, GetStaticPathsResult, GetStaticProps} from 'next'; import React from 'react'; import {Section} from 'src/components/NavigationLayout/types'; -import {Component} from '../../../../components/Component/Component'; -import {ComponentsLayout} from '../../../../components/ComponentsLayout/ComponentsLayout'; -import {Layout} from '../../../../components/Layout/Layout'; -import {libs} from '../../../../content/components'; -import {useLocaleRedirect} from '../../../../hooks/useLocaleRedirect'; -import {getLibComponents} from '../../../../utils'; -import {getI18nPaths, getI18nProps} from '../../../../utils/i18next'; +import {Component} from '../../../components/Component/Component'; +import {ComponentsLayout} from '../../../components/ComponentsLayout/ComponentsLayout'; +import {Layout} from '../../../components/Layout/Layout'; +import {libs} from '../../../content/components'; +import {useLocaleRedirect} from '../../../hooks/useLocaleRedirect'; +import {getLibComponents} from '../../../utils'; +import {getI18nPaths, getI18nProps} from '../../../utils/i18next'; export const getStaticPaths: GetStaticPaths = async () => { const paths = getI18nPaths().reduce((acc, localeItem) => { diff --git a/src/pages/[locale]/components/[libId]/index.tsx b/src/[locale]/components/[libId]/index.tsx similarity index 92% rename from src/pages/[locale]/components/[libId]/index.tsx rename to src/[locale]/components/[libId]/index.tsx index d43d30b4d87..bf783dc1aad 100644 --- a/src/pages/[locale]/components/[libId]/index.tsx +++ b/src/[locale]/components/[libId]/index.tsx @@ -3,9 +3,9 @@ import {useTranslation} from 'next-i18next'; import {useRouter} from 'next/router'; import React from 'react'; -import {Layout} from '../../../../components/Layout/Layout'; -import {libs} from '../../../../content/components'; -import {getI18nPaths, getI18nProps, getLocaleLink} from '../../../../utils'; +import {Layout} from '../../../components/Layout/Layout'; +import {libs} from '../../../content/components'; +import {getI18nPaths, getI18nProps, getLocaleLink} from '../../../utils'; export const getStaticPaths: GetStaticPaths = async () => { const paths = getI18nPaths().reduce((acc, localeItem) => { diff --git a/src/pages/[locale]/components/index.tsx b/src/[locale]/components/index.tsx similarity index 83% rename from src/pages/[locale]/components/index.tsx rename to src/[locale]/components/index.tsx index a9142c34ff6..2f16439f400 100644 --- a/src/pages/[locale]/components/index.tsx +++ b/src/[locale]/components/index.tsx @@ -3,9 +3,9 @@ import {useTranslation} from 'next-i18next'; import {useRouter} from 'next/router'; import React from 'react'; -import {Layout} from '../../../components/Layout/Layout'; -import {libs} from '../../../content/components'; -import {getI18nPaths, getI18nProps, getLocaleLink} from '../../../utils'; +import {Layout} from '../../components/Layout/Layout'; +import {libs} from '../../content/components'; +import {getI18nPaths, getI18nProps, getLocaleLink} from '../../utils'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/[locale]/design/[sectionId]/[articleId].tsx b/src/[locale]/design/[sectionId]/[articleId].tsx similarity index 85% rename from src/pages/[locale]/design/[sectionId]/[articleId].tsx rename to src/[locale]/design/[sectionId]/[articleId].tsx index 5d63046f878..4aeb57700aa 100644 --- a/src/pages/[locale]/design/[sectionId]/[articleId].tsx +++ b/src/[locale]/design/[sectionId]/[articleId].tsx @@ -2,12 +2,12 @@ import {GetStaticPaths, GetStaticPathsResult, GetStaticProps} from 'next'; import React from 'react'; import {Section} from 'src/components/NavigationLayout/types'; -import {DesignArticle} from '../../../../components/DesignArticle/DesignArticle'; -import {DesignLayout} from '../../../../components/DesignLayout/DesignLayout'; -import {Layout} from '../../../../components/Layout/Layout'; -import {sections as designSections} from '../../../../content/design'; -import {useLocaleRedirect} from '../../../../hooks/useLocaleRedirect'; -import {getI18nPaths, getI18nProps} from '../../../../utils/i18next'; +import {DesignArticle} from '../../../components/DesignArticle/DesignArticle'; +import {DesignLayout} from '../../../components/DesignLayout/DesignLayout'; +import {Layout} from '../../../components/Layout/Layout'; +import {sections as designSections} from '../../../content/design'; +import {useLocaleRedirect} from '../../../hooks/useLocaleRedirect'; +import {getI18nPaths, getI18nProps} from '../../../utils/i18next'; export const getStaticPaths: GetStaticPaths = async () => { const paths = getI18nPaths().reduce((acc, localeItem) => { diff --git a/src/pages/[locale]/design/[sectionId]/index.tsx b/src/[locale]/design/[sectionId]/index.tsx similarity index 92% rename from src/pages/[locale]/design/[sectionId]/index.tsx rename to src/[locale]/design/[sectionId]/index.tsx index 25324314d63..d1640e22a77 100644 --- a/src/pages/[locale]/design/[sectionId]/index.tsx +++ b/src/[locale]/design/[sectionId]/index.tsx @@ -3,9 +3,9 @@ import {useTranslation} from 'next-i18next'; import {useRouter} from 'next/router'; import React from 'react'; -import {Layout} from '../../../../components/Layout/Layout'; -import {sections} from '../../../../content/design'; -import {getI18nPaths, getI18nProps, getLocaleLink} from '../../../../utils'; +import {Layout} from '../../../components/Layout/Layout'; +import {sections} from '../../../content/design'; +import {getI18nPaths, getI18nProps, getLocaleLink} from '../../../utils'; export const getStaticPaths: GetStaticPaths = async () => { const paths = getI18nPaths().reduce((acc, localeItem) => { diff --git a/src/pages/[locale]/design/index.tsx b/src/[locale]/design/index.tsx similarity index 86% rename from src/pages/[locale]/design/index.tsx rename to src/[locale]/design/index.tsx index 648a19d7eaa..d89b39a0d58 100644 --- a/src/pages/[locale]/design/index.tsx +++ b/src/[locale]/design/index.tsx @@ -3,9 +3,9 @@ import {useTranslation} from 'next-i18next'; import {useRouter} from 'next/router'; import React from 'react'; -import {Layout} from '../../../components/Layout/Layout'; -import {sections} from '../../../content/design'; -import {getI18nPaths, getI18nProps, getLocaleLink} from '../../../utils'; +import {Layout} from '../../components/Layout/Layout'; +import {sections} from '../../content/design'; +import {getI18nPaths, getI18nProps, getLocaleLink} from '../../utils'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/[locale]/icons.tsx b/src/[locale]/icons.tsx similarity index 85% rename from src/pages/[locale]/icons.tsx rename to src/[locale]/icons.tsx index e64ac18e216..278adca2020 100644 --- a/src/pages/[locale]/icons.tsx +++ b/src/[locale]/icons.tsx @@ -2,10 +2,10 @@ import {GetStaticPaths, GetStaticProps} from 'next'; import {useRouter} from 'next/router'; import React from 'react'; -import {Icons} from '../../components/Icons'; -import {Layout} from '../../components/Layout/Layout'; -import {useLocaleRedirect} from '../../hooks/useLocaleRedirect'; -import {getI18nPaths, getI18nProps} from '../../utils/i18next'; +import {Icons} from '../components/Icons'; +import {Layout} from '../components/Layout/Layout'; +import {useLocaleRedirect} from '../hooks/useLocaleRedirect'; +import {getI18nPaths, getI18nProps} from '../utils/i18next'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/[locale]/index.tsx b/src/[locale]/index.tsx similarity index 69% rename from src/pages/[locale]/index.tsx rename to src/[locale]/index.tsx index 799293a713f..25fb1099b27 100644 --- a/src/pages/[locale]/index.tsx +++ b/src/[locale]/index.tsx @@ -1,9 +1,9 @@ import {GetStaticPaths, GetStaticProps} from 'next'; -import {Landing} from '../../components/Landing/Landing'; -import {Layout} from '../../components/Layout/Layout'; -import {useLocaleRedirect} from '../../hooks/useLocaleRedirect'; -import {getI18nPaths, getI18nProps} from '../../utils/i18next'; +import {Landing} from '../components/Landing/Landing'; +import {Layout} from '../components/Layout/Layout'; +import {useLocaleRedirect} from '../hooks/useLocaleRedirect'; +import {getI18nPaths, getI18nProps} from '../utils/i18next'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/[locale]/libraries/[libId].tsx b/src/[locale]/libraries/[libId].tsx similarity index 84% rename from src/pages/[locale]/libraries/[libId].tsx rename to src/[locale]/libraries/[libId].tsx index 73553b21552..2461e1321ed 100644 --- a/src/pages/[locale]/libraries/[libId].tsx +++ b/src/[locale]/libraries/[libId].tsx @@ -1,9 +1,9 @@ import {GetStaticPaths, GetStaticPathsResult, GetStaticProps} from 'next'; -import {Layout} from '../../../components/Layout/Layout'; -import {Library} from '../../../components/Library/Library'; -import {useLocaleRedirect} from '../../../hooks/useLocaleRedirect'; -import {getI18nPaths, getI18nProps, getLibById, getLibsList} from '../../../utils'; +import {Layout} from '../../components/Layout/Layout'; +import {Library} from '../../components/Library/Library'; +import {useLocaleRedirect} from '../../hooks/useLocaleRedirect'; +import {getI18nPaths, getI18nProps, getLibById, getLibsList} from '../../utils'; const libs = getLibsList(); diff --git a/src/pages/[locale]/libraries/index.tsx b/src/[locale]/libraries/index.tsx similarity index 72% rename from src/pages/[locale]/libraries/index.tsx rename to src/[locale]/libraries/index.tsx index ac2e52b4440..fa59366ffd5 100644 --- a/src/pages/[locale]/libraries/index.tsx +++ b/src/[locale]/libraries/index.tsx @@ -1,10 +1,10 @@ import {GetStaticPaths, GetStaticProps} from 'next'; import {useTranslation} from 'next-i18next'; -import {Layout} from '../../../components/Layout/Layout'; -import {Libraries} from '../../../components/Libraries/Libraries'; -import {useLocaleRedirect} from '../../../hooks/useLocaleRedirect'; -import {getI18nPaths, getI18nProps} from '../../../utils/i18next'; +import {Layout} from '../../components/Layout/Layout'; +import {Libraries} from '../../components/Libraries/Libraries'; +import {useLocaleRedirect} from '../../hooks/useLocaleRedirect'; +import {getI18nPaths, getI18nProps} from '../../utils/i18next'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/components/Menu/LocalePicker/LocalePicker.tsx b/src/components/Menu/LocalePicker/LocalePicker.tsx index 8c19fc46a44..34353b1210a 100644 --- a/src/components/Menu/LocalePicker/LocalePicker.tsx +++ b/src/components/Menu/LocalePicker/LocalePicker.tsx @@ -13,6 +13,10 @@ export const LocalePicker: React.FC = () => { const {i18n} = useTranslation(); const router = useRouter(); + if (i18nextConfig.i18n.locales.length < 2) { + return null; + } + return (
{ const localStorageLocale = localStorage.getItem(LOCALE_LOCAL_STORAGE_KEY); - const correctLocale = localStorageLocale - ? localStorageLocale - : i18nextConfig.i18n.defaultLocale; + const correctLocale = + localStorageLocale && i18nextConfig.i18n.locales.includes(localStorageLocale) + ? localStorageLocale + : i18nextConfig.i18n.defaultLocale; if (currentLocale !== correctLocale) { const currentPath = router.asPath; diff --git a/src/pages/components/[libId]/[componentId].tsx b/src/pages/components/[libId]/[componentId].tsx index 36ab5dcc68e..d33a29b466c 100644 --- a/src/pages/components/[libId]/[componentId].tsx +++ b/src/pages/components/[libId]/[componentId].tsx @@ -1,8 +1,8 @@ // Support for default locale without path prefix import {GetStaticPaths} from 'next'; +import {ComponentPage, getStaticProps} from '../../../[locale]/components/[libId]/[componentId]'; import {libs} from '../../../content/components'; -import {ComponentPage, getStaticProps} from '../../[locale]/components/[libId]/[componentId]'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/components/[libId]/index.tsx b/src/pages/components/[libId]/index.tsx index 65b3f615463..a09192c1b77 100644 --- a/src/pages/components/[libId]/index.tsx +++ b/src/pages/components/[libId]/index.tsx @@ -1,8 +1,8 @@ // Support for default locale without path prefix import {GetStaticPaths} from 'next'; +import {LibraryComponentsPage, getStaticProps} from '../../../[locale]/components/[libId]'; import {libs} from '../../../content/components'; -import {LibraryComponentsPage, getStaticProps} from '../../[locale]/components/[libId]'; export const getStaticPaths: GetStaticPaths = async () => { const paths = libs.map((libItem) => ({ diff --git a/src/pages/components/index.tsx b/src/pages/components/index.tsx index c7d5b5bdb98..09c96ba5bb4 100644 --- a/src/pages/components/index.tsx +++ b/src/pages/components/index.tsx @@ -1,2 +1,2 @@ // Support for default locale without path prefix -export {default, getStaticProps} from '../[locale]/components'; +export {default, getStaticProps} from '../../[locale]/components'; diff --git a/src/pages/design/[sectionId]/[articleId].tsx b/src/pages/design/[sectionId]/[articleId].tsx index ae53daf2620..0c2867d4061 100644 --- a/src/pages/design/[sectionId]/[articleId].tsx +++ b/src/pages/design/[sectionId]/[articleId].tsx @@ -1,8 +1,8 @@ // Support for default locale without path prefix import {GetStaticPaths} from 'next'; +import {ArticlePage, getStaticProps} from '../../../[locale]/design/[sectionId]/[articleId]'; import {sections as designSections} from '../../../content/design'; -import {ArticlePage, getStaticProps} from '../../[locale]/design/[sectionId]/[articleId]'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/design/[sectionId]/index.tsx b/src/pages/design/[sectionId]/index.tsx index beb831873ee..d72da184a22 100644 --- a/src/pages/design/[sectionId]/index.tsx +++ b/src/pages/design/[sectionId]/index.tsx @@ -1,8 +1,8 @@ // Support for default locale without path prefix import {GetStaticPaths} from 'next'; +import {DesignSectionPage, getStaticProps} from '../../../[locale]/design/[sectionId]'; import {sections} from '../../../content/design'; -import {DesignSectionPage, getStaticProps} from '../../[locale]/design/[sectionId]'; export const getStaticPaths: GetStaticPaths = async () => { return { diff --git a/src/pages/design/index.tsx b/src/pages/design/index.tsx index e84eac42041..6bb7fd8f86f 100644 --- a/src/pages/design/index.tsx +++ b/src/pages/design/index.tsx @@ -1,2 +1,2 @@ // Support for default locale without path prefix -export {default, getStaticProps} from '../[locale]/design'; +export {default, getStaticProps} from '../../[locale]/design'; diff --git a/src/pages/icons.tsx b/src/pages/icons.tsx index 218b0004f56..de6d526cd88 100644 --- a/src/pages/icons.tsx +++ b/src/pages/icons.tsx @@ -1,2 +1,2 @@ // Support for default locale without path prefix -export {default, getStaticProps} from './[locale]/icons'; +export {default, getStaticProps} from '../[locale]/icons'; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index be36db96306..59fb7df8381 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,2 +1,2 @@ // Support for default locale without path prefix -export {default, getStaticProps} from './[locale]/index'; +export {default, getStaticProps} from '../[locale]/index'; diff --git a/src/pages/libraries/[libId].tsx b/src/pages/libraries/[libId].tsx index f4a37bd55b1..77f790f837d 100644 --- a/src/pages/libraries/[libId].tsx +++ b/src/pages/libraries/[libId].tsx @@ -1,8 +1,8 @@ // Support for default locale without path prefix import {GetStaticPaths} from 'next'; +import {LibraryPage, getStaticProps} from '../../[locale]/libraries/[libId]'; import {getLibsList} from '../../utils'; -import {LibraryPage, getStaticProps} from '../[locale]/libraries/[libId]'; const libs = getLibsList(); diff --git a/src/pages/libraries/index.tsx b/src/pages/libraries/index.tsx index c7f2b9d9952..8c7023c64c7 100644 --- a/src/pages/libraries/index.tsx +++ b/src/pages/libraries/index.tsx @@ -1,2 +1,2 @@ // Support for default locale without path prefix -export {default, getStaticProps} from '../[locale]/libraries'; +export {default, getStaticProps} from '../../[locale]/libraries';