diff --git a/i18n.json b/i18n.json new file mode 100644 index 0000000..9ad0d3a --- /dev/null +++ b/i18n.json @@ -0,0 +1,5 @@ +{ + "defaultLocale": "en", + "locales": ["fr", "en"], + "pages": { "*": ["common"], "/": ["home"] } +} diff --git a/locales/en/common.json b/locales/en/common.json new file mode 100644 index 0000000..21d999a --- /dev/null +++ b/locales/en/common.json @@ -0,0 +1,3 @@ +{ + "walidoux-github": "Walidoux's Github" +} diff --git a/locales/en/home.json b/locales/en/home.json new file mode 100644 index 0000000..79dd280 --- /dev/null +++ b/locales/en/home.json @@ -0,0 +1,4 @@ +{ + "title": "You feel a calming tranquility...", + "subtitle": "You're filled with determination." +} diff --git a/locales/fr/common.json b/locales/fr/common.json new file mode 100644 index 0000000..21930e2 --- /dev/null +++ b/locales/fr/common.json @@ -0,0 +1,3 @@ +{ + "walidoux-github": "Github de Walidoux" +} diff --git a/locales/fr/home.json b/locales/fr/home.json new file mode 100644 index 0000000..dafde7a --- /dev/null +++ b/locales/fr/home.json @@ -0,0 +1,4 @@ +{ + "title": "Vous ressentez une tranquillité apaisante...", + "subtitle": "Vous êtes rempli de détermination." +} diff --git a/next.config.js b/next.config.js index 9331f0e..e24fc0c 100644 --- a/next.config.js +++ b/next.config.js @@ -1,9 +1,9 @@ -// @ts-check - const path = require('path') +const nextTranslate = require('next-translate') + /** @type {import('next').NextConfig} */ -module.exports = { +const nextConfig = { reactStrictMode: true, swcMinify: true, sassOptions: { @@ -13,3 +13,5 @@ module.exports = { ] } } + +module.exports = nextTranslate(nextConfig) diff --git a/pages/_app.tsx b/pages/_app.tsx index 891f80d..6ab52ed 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,8 +1,20 @@ +import { useEffect } from 'react' import type { AppProps } from 'next/app' +import useTranslation from 'next-translate/useTranslation' +import Cookies from 'js-cookie' import '../styles/main.scss' const MyApp = ({ Component, pageProps }: AppProps): JSX.Element => { + const { lang } = useTranslation() + + // 10 years before cookie's expiration + const COOKIE_EXPIRATION = 10 * 365.25 * 24 * 60 * 60 + + useEffect(() => { + Cookies.set('NEXT_LOCALE', lang, { expires: COOKIE_EXPIRATION }) + }, [lang, COOKIE_EXPIRATION]) + return } diff --git a/pages/index.tsx b/pages/index.tsx index 2f89f1e..c0df251 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,26 +1,27 @@ import type { NextPage } from 'next' -import { GitHub } from 'react-feather' +import { FiGithub } from 'react-icons/fi' import Link from 'next/link' +import useTranslation from 'next-translate/useTranslation' -import Head from 'components/Head/NextHead' +import NextHead from 'components/NextHead' import styles from '../styles/pages/home.module.scss' const Home: NextPage = () => { + const { t } = useTranslation() + return (
- +

- You feel a calming tranquility...
- - You're filled with determination. - + {t('home:title')}
+ {t('home:subtitle')}

- - Walidoux's Github + + {t('common:walidoux-github')}