feat: implement next-translation
This commit is contained in:
		
							
								
								
									
										5
									
								
								i18n.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								i18n.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| { | ||||
|   "defaultLocale": "en", | ||||
|   "locales": ["fr", "en"], | ||||
|   "pages": { "*": ["common"], "/": ["home"] } | ||||
| } | ||||
							
								
								
									
										3
									
								
								locales/en/common.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								locales/en/common.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| { | ||||
|   "walidoux-github": "Walidoux's Github" | ||||
| } | ||||
							
								
								
									
										4
									
								
								locales/en/home.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								locales/en/home.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| { | ||||
|   "title": "You feel a calming tranquility...", | ||||
|   "subtitle": "You're filled with determination." | ||||
| } | ||||
							
								
								
									
										3
									
								
								locales/fr/common.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								locales/fr/common.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| { | ||||
|   "walidoux-github": "Github de Walidoux" | ||||
| } | ||||
							
								
								
									
										4
									
								
								locales/fr/home.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								locales/fr/home.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| { | ||||
|   "title": "Vous ressentez une tranquillité apaisante...", | ||||
|   "subtitle": "Vous êtes rempli de détermination." | ||||
| } | ||||
| @@ -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) | ||||
|   | ||||
| @@ -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 <Component {...pageProps} /> | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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 ( | ||||
|     <main className={styles.application}> | ||||
|       <Head /> | ||||
|       <NextHead /> | ||||
|  | ||||
|       <p className={styles.title}> | ||||
|         You feel a calming tranquility... <br /> | ||||
|         <span className={styles.subtitle}> | ||||
|           You're filled with determination. | ||||
|         </span> | ||||
|         {t('home:title')} <br /> | ||||
|         <span className={styles.subtitle}>{t('home:subtitle')}</span> | ||||
|       </p> | ||||
|       <Link href='https://github.com/Walidoux'> | ||||
|         <a className={styles['redirect-link']} target='_blank'> | ||||
|           <GitHub /> | ||||
|           <span className={styles.text}>Walidoux's Github</span> | ||||
|           <FiGithub fontSize={20} /> | ||||
|           <span className={styles.text}>{t('common:walidoux-github')}</span> | ||||
|         </a> | ||||
|       </Link> | ||||
|     </main> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user