generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: install and configure react-i18next
- Loading branch information
Showing
8 changed files
with
139 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import i18n from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
|
||
// Initialize i18next | ||
i18n.use(initReactI18next).init({ | ||
resources: { | ||
en: { | ||
translation: require('../../locales/en.json'), | ||
}, | ||
it: { | ||
translation: require('../../locales/it.json'), | ||
}, | ||
}, | ||
lng: 'en', // Default language | ||
fallbackLng: 'en', // Fallback language | ||
interpolation: { | ||
escapeValue: false, // Allow interpolation in translations | ||
}, | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,32 @@ | ||
'use client'; | ||
|
||
import { ReactNode } from 'react'; | ||
import { I18nextProvider } from 'react-i18next'; | ||
|
||
import '@/styles/globals.css'; | ||
import '@/styles/animations.css'; | ||
|
||
import LayoutClient from '@/app/(public)/layout-client'; | ||
|
||
import i18n from './i18n'; | ||
|
||
export default function RootLayout({ children }: { children: ReactNode }) { | ||
return ( | ||
<html lang='en'> | ||
<head> | ||
<title>MartaCodes.it</title> | ||
<link | ||
rel='icon' | ||
type='image/png' | ||
sizes='32x32' | ||
href='/favicon/favicon.ico' | ||
/> | ||
</head> | ||
<body> | ||
<LayoutClient>{children}</LayoutClient> | ||
</body> | ||
</html> | ||
<I18nextProvider i18n={i18n}> | ||
<html lang='en'> | ||
<head> | ||
<title>MartaCodes.it</title> | ||
<link | ||
rel='icon' | ||
type='image/png' | ||
sizes='32x32' | ||
href='/favicon/favicon.ico' | ||
/> | ||
</head> | ||
<body> | ||
<LayoutClient>{children}</LayoutClient> | ||
</body> | ||
</html> | ||
</I18nextProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface HeadingProps { | ||
title: string; | ||
} | ||
|
||
const Heading = ({ title }: HeadingProps) => { | ||
const { t } = useTranslation(); | ||
|
||
return <h1 className='mb-5'>{t(title)}</h1>; | ||
}; | ||
|
||
export default Heading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"aboutWork": { | ||
"title": "Work & Career", | ||
"softwareDevelopment": { | ||
"title": "Software Development", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692734473/laptop_4a3ba3b30c.svg" | ||
}, | ||
"workExperience": { | ||
"title": "Work Experience", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/work_f1bb1eb3dd.svg" | ||
}, | ||
"education": { | ||
"title": "Education", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/school_bbe225685d.svg" | ||
}, | ||
"languages": { | ||
"title": "Work Experience", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/internet_60bf166c34.svg" | ||
}, | ||
"publications": { | ||
"title": "Publications", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/newspaper_e15ec94d21.svg" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"aboutWork": { | ||
"title": "Carriera Lavorativa", | ||
"softwareDevelopment": { | ||
"title": "Sviluppo Software", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692734473/laptop_4a3ba3b30c.svg" | ||
}, | ||
"workExperience": { | ||
"title": "Work Experience", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/work_f1bb1eb3dd.svg" | ||
}, | ||
"education": { | ||
"title": "Education", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/school_bbe225685d.svg" | ||
}, | ||
"languages": { | ||
"title": "Work Experience", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/internet_60bf166c34.svg" | ||
}, | ||
"publications": { | ||
"title": "Publications", | ||
"icon": "https://res.cloudinary.com/dwrurydlt/image/upload/v1692894192/newspaper_e15ec94d21.svg" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters