diff --git a/i18n.js b/i18n.js
deleted file mode 100644
index cacafd8..0000000
--- a/i18n.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/** @type {import('next-i18next').UserConfig} */
-
-module.exports = {
- i18n: {
- defaultLocale: "pt-br",
- locales: [
- "pt-br", // Portuguese (Brazil)
- "en-us", // English (USA)
- "fr-fr", // French (France)
- "es-es", // Spanish (Spain)
- "ko-ko", // Korean (South Korea)
- "ja-ja", // Japanese (Japan)
- "de-de", // German (Germany)
- "it-it", // Italian (Italy)
- "zh-cn", // Chinese (Simplified, Mainland China)
- "ar-sa", // Arabic
- ],
- localeDetection: false,
- },
-};
diff --git a/next-i18next.config.js b/next-i18next.config.js
new file mode 100644
index 0000000..f71c9df
--- /dev/null
+++ b/next-i18next.config.js
@@ -0,0 +1,21 @@
+/** @type {import('next-i18next').UserConfig} */
+
+module.exports = {
+ i18n: {
+ defaultLocale: 'en',
+ locales: [
+ 'pt', // Portuguese (Brazil)
+ 'en', // English (USA)
+ 'fr', // French (France)
+ 'es', // Spanish (Spain)
+ 'ko', // Korean (South Korea)
+ 'ja', // Japanese (Japan)
+ 'de', // German (Germany)
+ 'it', // Italian (Italy)
+ 'zh', // Chinese (Simplified, Mainland China)
+ 'ar', // Arabic
+ ],
+ localeDetection: true,
+ reloadOnPrerender: process.env.NODE_ENV === 'development',
+ },
+};
diff --git a/next.config.js b/next.config.js
index 591f038..46aca5f 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,19 +1,19 @@
/* eslint-disable import/no-extraneous-dependencies */
-const withBundleAnalyzer = require("@next/bundle-analyzer")({
- enabled: process.env.ANALYZE === "true",
+const withBundleAnalyzer = require('@next/bundle-analyzer')({
+ enabled: process.env.ANALYZE === 'true',
});
-const { i18n } = require("./i18n");
+// const { i18n } = require("./i18n");
module.exports = withBundleAnalyzer({
eslint: {
- dirs: ["."],
+ dirs: ['.'],
},
poweredByHeader: false,
trailingSlash: true,
- basePath: "",
+ basePath: '',
// The starter code load resources from `public` folder with `router.basePath` in React components.
// So, the source code is "basePath-ready".
// You can remove `basePath` if you don't need it.
reactStrictMode: true,
- i18n,
+ // i18n,
});
diff --git a/public/locales/ar-sa/common.json b/public/locales/ar/common.json
similarity index 100%
rename from public/locales/ar-sa/common.json
rename to public/locales/ar/common.json
diff --git a/public/locales/de-de/common.json b/public/locales/de/common.json
similarity index 100%
rename from public/locales/de-de/common.json
rename to public/locales/de/common.json
diff --git a/public/locales/en-us/common.json b/public/locales/en/common.json
similarity index 100%
rename from public/locales/en-us/common.json
rename to public/locales/en/common.json
diff --git a/public/locales/es-es/common.json b/public/locales/es/common.json
similarity index 100%
rename from public/locales/es-es/common.json
rename to public/locales/es/common.json
diff --git a/public/locales/fr-fr/common.json b/public/locales/fr/common.json
similarity index 100%
rename from public/locales/fr-fr/common.json
rename to public/locales/fr/common.json
diff --git a/public/locales/it-it/common.json b/public/locales/it/common.json
similarity index 100%
rename from public/locales/it-it/common.json
rename to public/locales/it/common.json
diff --git a/public/locales/ja-ja/common.json b/public/locales/ja/common.json
similarity index 100%
rename from public/locales/ja-ja/common.json
rename to public/locales/ja/common.json
diff --git a/public/locales/ko-ko/common.json b/public/locales/ko/common.json
similarity index 100%
rename from public/locales/ko-ko/common.json
rename to public/locales/ko/common.json
diff --git a/public/locales/pt-br/common.json b/public/locales/pt/common.json
similarity index 100%
rename from public/locales/pt-br/common.json
rename to public/locales/pt/common.json
diff --git a/public/locales/zh-cn/common.json b/public/locales/zh/common.json
similarity index 100%
rename from public/locales/zh-cn/common.json
rename to public/locales/zh/common.json
diff --git a/src/components/Link/index.tsx b/src/components/Link/index.tsx
index e313290..cb24f0e 100644
--- a/src/components/Link/index.tsx
+++ b/src/components/Link/index.tsx
@@ -1,16 +1,47 @@
+import type { LinkProps } from 'next/link';
+import NextLink from 'next/link';
+import { useRouter } from 'next/router';
import React from 'react';
-interface Props
- extends React.DetailedHTMLProps<
- React.AnchorHTMLAttributes,
- HTMLAnchorElement
- > {}
+interface Props extends LinkProps {
+ skipLocaleHandling?: boolean;
+ locale?: string;
+ target?: string;
+ className?: string;
+ children?: React.ReactNode;
+}
+
+const LinkComponent = ({
+ children,
+ skipLocaleHandling,
+ href: propsHref,
+ ...rest
+}: Props) => {
+ const router = useRouter();
+ const locale = rest.locale || router.query.locale;
+
+ let href = propsHref || router.asPath;
+ if (href.indexOf('http') === 0) skipLocaleHandling = true;
+ if (locale && !skipLocaleHandling) {
+ href = href
+ ? `/${locale}${href}`
+ : router.pathname.replace('[locale]', locale);
+ }
+
+ return (
+ <>
+
+ {children}
+
+ >
+ );
+};
export default function Link({ children, ...props }: Props) {
return (
-
+
{children}
-
+
);
}
diff --git a/src/pages/[locale]/index.tsx b/src/pages/[locale]/index.tsx
index 4690dfc..b37633c 100644
--- a/src/pages/[locale]/index.tsx
+++ b/src/pages/[locale]/index.tsx
@@ -3,35 +3,35 @@ import {
LinkedinOutlined,
MailOutlined,
WhatsAppOutlined,
-} from "@ant-design/icons";
-import dynamic from "next/dynamic";
-import { useRouter } from "next/router";
-import { useTranslation } from "next-i18next";
-import { useEffect, useState } from "react";
+} from '@ant-design/icons';
+import dynamic from 'next/dynamic';
+import { useRouter } from 'next/router';
+import { useTranslation } from 'next-i18next';
+import { useEffect, useState } from 'react';
-import CertificateCard from "@/components/CertificateCard";
-import Footer from "@/components/Footer";
-import Icon from "@/components/Icon";
-import { SocialLink } from "@/components/Link";
-import ProjectGrid from "@/components/ProjectGrid";
-import Scroll from "@/components/Scroll";
-import Timeline from "@/components/Timeline";
-import Block from "@/layouts/Block";
-import { Meta } from "@/layouts/Meta";
-import Row from "@/layouts/Row";
-import profile from "@/public/assets/jsons/profile.json";
-import { apiFetch } from "@/services";
-import { Main } from "@/templates/Main";
-import { capitalize, isProgrammingLanguage } from "@/utils";
-import { getStaticPaths, makeStaticProps } from "@/utils/getStatic";
+import CertificateCard from '@/components/CertificateCard';
+import Footer from '@/components/Footer';
+import Icon from '@/components/Icon';
+import { SocialLink } from '@/components/Link';
+import ProjectGrid from '@/components/ProjectGrid';
+import Scroll from '@/components/Scroll';
+import Timeline from '@/components/Timeline';
+import Block from '@/layouts/Block';
+import { Meta } from '@/layouts/Meta';
+import Row from '@/layouts/Row';
+import profile from '@/public/assets/jsons/profile.json';
+import { apiFetch } from '@/services';
+import { Main } from '@/templates/Main';
+import { capitalize, isProgrammingLanguage } from '@/utils';
+import { getStaticPaths, makeStaticProps } from '@/utils/getStatic';
import {
GITHUB_PINNED_REPO,
GITHUB_REPO,
WAKATIME_CODING_TIME,
WAKATIME_LANGUAGES,
-} from "@/utils/url";
+} from '@/utils/url';
-const LanguageChart = dynamic(() => import("@/components/LanguageChart"), {
+const LanguageChart = dynamic(() => import('@/components/LanguageChart'), {
ssr: false,
});
@@ -40,7 +40,7 @@ const Index = () => {
const [data, setData] = useState([]);
const [pinnedRepos, setPinnedRepos] = useState([]);
- const { t } = useTranslation("common");
+ const { t } = useTranslation('common');
const {
firstName,
lastName,
@@ -72,7 +72,7 @@ const Index = () => {
r.map((v: any) => ({
...v,
url: GITHUB_REPO(username, v.name),
- name: capitalize(v.name?.replace(/-/g, " ")),
+ name: capitalize(v.name?.replace(/-/g, ' ')),
}))
);
const totalSeconds =
@@ -116,7 +116,7 @@ const Index = () => {
}
>
@@ -135,14 +135,14 @@ const Index = () => {
-
+
-
+
@@ -152,7 +152,7 @@ const Index = () => {
*/}
-
+
@@ -162,7 +162,7 @@ const Index = () => {
*/}
-
+
@@ -174,8 +174,8 @@ const Index = () => {
@@ -201,7 +201,7 @@ const Index = () => {
id="about"
className="mb-3 text-xl font-semibold text-black md:text-4xl "
>
- {t("About Me")}
+ {t('About Me')}
{t(bio)}
@@ -217,7 +217,7 @@ const Index = () => {
id="languages"
className="mb-3 text-xl font-semibold text-black md:text-4xl "
>
- {t("Languages")}
+ {t('Languages')}
@@ -228,7 +228,7 @@ const Index = () => {
id="experience"
className="mb-3 text-xl font-semibold text-black md:text-4xl "
>
- {t("Experiences")}
+ {t('Experiences')}
@@ -241,7 +241,7 @@ const Index = () => {
id="education"
className="mb-3 text-xl font-semibold text-black md:text-4xl "
>
- {t("Educations")}
+ {t('Educations')}
@@ -252,7 +252,7 @@ const Index = () => {
id="certification"
className="mb-3 text-xl font-semibold text-black md:text-4xl "
>
- {t("Certifications")}
+ {t('Certifications')}
{certification?.map((v, key) => (
@@ -271,7 +271,7 @@ const Index = () => {
id="projects"
className="mb-3 text-xl font-semibold text-black md:text-4xl "
>
- {t("Projects")}
+ {t('Projects')}
{
};
export default Index;
-const getStaticProps = makeStaticProps(["common"]);
+const getStaticProps = makeStaticProps(['common']);
export { getStaticPaths, getStaticProps };
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx
index 3982d92..e67c721 100644
--- a/src/pages/_document.tsx
+++ b/src/pages/_document.tsx
@@ -1,13 +1,15 @@
/* eslint-disable no-underscore-dangle */
import Document, { Head, Html, Main, NextScript } from 'next/document';
-const i18nextConfig = require("../../i18n");
+const i18nextConfig = require('../../next-i18next.config');
// Need to create a custom _document because i18n support is not compatible with `next export`.
class MyDocument extends Document {
// eslint-disable-next-line class-methods-use-this
render() {
const currentLocale =
this.props.__NEXT_DATA__.query.locale || i18nextConfig.i18n.defaultLocale;
+
+ console.log('locale', currentLocale);
return (
diff --git a/src/utils/getStatic.ts b/src/utils/getStatic.ts
index c453576..2f98432 100644
--- a/src/utils/getStatic.ts
+++ b/src/utils/getStatic.ts
@@ -1,6 +1,6 @@
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
-const i18nextConfig = require("../../i18n");
+const i18nextConfig = require("../../next-i18next.config");
export const getI18nPaths = () =>
i18nextConfig.i18n.locales.map((lng: string) => ({
@@ -16,6 +16,7 @@ export const getStaticPaths = () => ({
export const getI18nProps = async (ctx: any, ns = ["common"]) => {
const locale = ctx?.params?.locale || i18nextConfig.i18n.defaultLocale;
+ console.log(ctx, ns);
const props = {
...(await serverSideTranslations(locale, ns)),
};
diff --git a/src/utils/languageDetector.ts b/src/utils/languageDetector.ts
index 9d99cb6..81f9829 100644
--- a/src/utils/languageDetector.ts
+++ b/src/utils/languageDetector.ts
@@ -1,6 +1,6 @@
import languageDetector from 'next-language-detector';
-const i18nextConfig = require('../../i18n');
+const i18nextConfig = require('../../next-i18next.config');
export default languageDetector({
fallbackLng: i18nextConfig.i18n.defaultLocale,