language i18n added and tested for server and client side
This commit is contained in:
29
ServicesFrontEnd/frontend/src/app/home-page.tsx
Normal file
29
ServicesFrontEnd/frontend/src/app/home-page.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
'use client';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useRouter } from '@/i18n/navigation';
|
||||
import { useParams } from 'next/navigation';
|
||||
import LocaleSwitcherClient from '@/components/LocaleSwitcherClient';
|
||||
|
||||
export default function HomePage() {
|
||||
const t = useTranslations('Index');
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
|
||||
const handleNavigation = (path: string) => {
|
||||
console.log('Navigating to /about');
|
||||
router.push(path);
|
||||
};
|
||||
|
||||
return (
|
||||
<main>
|
||||
<h1>{t('title')}</h1>
|
||||
<p>{t('description')}</p>
|
||||
<p>{t('navigation.title')} : {params.locale}</p>
|
||||
<div className='flex flex-col gap-2'>
|
||||
<LocaleSwitcherClient />
|
||||
<button onClick={() => handleNavigation('/about')}>{t('navigation.about')}</button>
|
||||
<button onClick={() => handleNavigation('/home')}>{t('navigation.home')}</button>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user