Skip to content

Commit

Permalink
refactor: remove unused dependencies/code relating to i18next
Browse files Browse the repository at this point in the history
- removes commented out code for i18next as well
  • Loading branch information
mohitb35 committed Mar 11, 2024
1 parent 3a2cc88 commit a64fe1d
Show file tree
Hide file tree
Showing 10 changed files with 431 additions and 490 deletions.
1 change: 1 addition & 0 deletions i18n-config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// i18n config for next-intl
export const i18nConfig = {
defaultLocale: 'en',
locales: ['en', 'de', 'cs', 'es', 'fr', 'it', 'pt-BR'],
Expand Down
2 changes: 0 additions & 2 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { getTenantSlug } from './src/utils/multiTenancy/helpers';
import { match as matchLocale } from '@formatjs/intl-localematcher';
import Negotiator from 'negotiator';
import { i18nConfig, Locale } from './i18n-config';
// import createIntlMiddleware from 'next-intl/middleware';

// TODO - update function to consider cookie
function getLocale(request: NextRequest): string | undefined {
// Negotiator expects plain object so we need to transform headers
const negotiatorHeaders: Record<string, string> = {};
Expand Down
10 changes: 0 additions & 10 deletions next-i18next.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
// const { i18n } = require('./next-i18next.config');

// Use the SentryWebpack plugin to upload the source maps during build step
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
Expand Down Expand Up @@ -49,7 +48,6 @@ const hasAssetPrefix =
/** @type {import('next').NextConfig} */
const nextConfig = {
productionBrowserSourceMaps: true,
// i18n,
serverRuntimeConfig: {
rootDir: __dirname,
},
Expand Down
860 changes: 425 additions & 435 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
"negotiator": "^0.6.3",
"next": "^13.5.6",
"next-connect": "^0.13.0",
"next-i18next": "^12.1.0",
"next-intl": "^3.5.3",
"next-useragent": "^2.7.0",
"node-cache": "^5.1.2",
Expand All @@ -116,7 +115,6 @@
"react-dropzone": "^11.4.0",
"react-gtm-module": "^2.0.11",
"react-hook-form": "^7.44.2",
"react-i18next": "^11.16.10",
"react-insta-stories": "^2.2.5",
"react-json-editor-ajrm": "^2.5.13",
"react-lazyload": "^3.2.0",
Expand Down Expand Up @@ -181,8 +179,6 @@
"eslint-plugin-react-hooks": "^4.1.2",
"eslint-plugin-storybook": "^0.6.15",
"husky": "^8.0.3",
"i18next-browser-languagedetector": "^7.2.0",
"i18next-http-backend": "^2.4.2",
"next-unused": "0.0.6",
"prettier": "^2.0.5",
"prisma": "^4.13.0",
Expand Down
20 changes: 0 additions & 20 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,10 @@ const PlanetWeb = ({
}
}

// const [initialized, setInitialized] = React.useState(false);

React.useEffect(() => {
storeConfig(tenantConfig);

Check notice on line 138 in pages/_app.tsx

View check run for this annotation

codefactor.io / CodeFactor

pages/_app.tsx#L113-L138

Complex Method
}, []);

/* React.useEffect(() => {
if (i18n && i18n.isInitialized) {
setInitialized(true);
}
}, [i18n, i18n.isInitialized]);*/

/* React.useEffect(() => {
if (
localStorage.getItem('language') !== null &&
i18n &&
i18n.isInitialized
) {
const languageFromLocalStorage: any = localStorage.getItem('language');
i18n.changeLanguage(languageFromLocalStorage);
}
}, [i18n, i18n.isInitialized]); */

React.useEffect(() => {
if (
router.pathname === '/' ||
Expand Down Expand Up @@ -184,7 +165,6 @@ const PlanetWeb = ({

const ProjectProps = {
pageProps,
// initialized,
currencyCode,
setCurrencyCode,
};
Expand Down
11 changes: 3 additions & 8 deletions pages/sites/[slug]/[locale]/all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import { AbstractIntlMessages } from 'next-intl';
import getMessagesForPage from '../../../../src/utils/language/getMessagesForPage';

interface Props {
initialized: Boolean;
pageProps: PageProps;
}

export default function Home({ initialized, pageProps }: Props) {
export default function Home({ pageProps }: Props) {
const [leaderboard, setLeaderboard] = React.useState<LeaderBoardList | null>(
null
);
Expand Down Expand Up @@ -99,12 +98,8 @@ export default function Home({ initialized, pageProps }: Props) {

return pageProps.tenantConfig ? (
<>
{initialized ? (
<>
<GetLeaderboardMeta />
{getAllPage()}
</>
) : null}
<GetLeaderboardMeta />
{getAllPage()}
</>
) : (
<></>
Expand Down
5 changes: 2 additions & 3 deletions pages/sites/[slug]/[locale]/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ import { AbstractIntlMessages } from 'next-intl';
import getMessagesForPage from '../../../../src/utils/language/getMessagesForPage';

interface Props {
initialized: Boolean;
pageProps: PageProps;
}

export default function Home({ initialized, pageProps }: Props) {
export default function Home({ pageProps }: Props) {
const router = useRouter();

const [leaderboard, setLeaderboard] = React.useState<LeaderBoardList | null>(
Expand Down Expand Up @@ -119,7 +118,7 @@ export default function Home({ initialized, pageProps }: Props) {
return pageProps.tenantConfig ? (
<>
<GetHomeMeta />
{initialized ? getHomePage() : <></>}
{getHomePage()}
</>
) : (
<></>
Expand Down
6 changes: 0 additions & 6 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const url = require('url');
const cluster = require('cluster');
const numCPUs = require('os').cpus().length;

// const i18next = require('./i18n');
// const nextI18NextMiddleware = require('next-i18next/middleware').default;

const dev = process.env.NODE_ENV !== 'production';
const port = process.env.PORT || 3000;

Expand All @@ -36,9 +33,6 @@ if (!dev && cluster.isMaster) {
nextApp.prepare().then(async () => {
const server = express();

// await i18next.initPromise;
// server.use(nextI18NextMiddleware(i18next));

if (!dev) {
// Enforce SSL & HSTS in production
// eslint-disable-next-line no-shadow
Expand Down

0 comments on commit a64fe1d

Please sign in to comment.