From 55c6a85180259321df2a55f8716d115b1e6add2c Mon Sep 17 00:00:00 2001 From: steveoni Date: Wed, 25 Nov 2020 16:04:52 +0100 Subject: [PATCH] [usecase][m]: experiment i18n on homeage --- packages/portal/pages/index.tsx | 71 ++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/packages/portal/pages/index.tsx b/packages/portal/pages/index.tsx index ad6a3f38..9c6fde8d 100644 --- a/packages/portal/pages/index.tsx +++ b/packages/portal/pages/index.tsx @@ -5,36 +5,48 @@ import Nav from '../components/home/Nav'; import Recent from '../components/home/Recent'; import Form from '../components/search/Form'; import { SEARCH_QUERY } from '../graphql/queries'; +import { loadNamespaces } from './_app'; +import useTranslation from 'next-translate/useTranslation'; -const Home: React.FC = () => ( -
- - Portal - - -
-); +const Home: React.FC<{ locale: any; locales: any }> = ({ + locale, + locales, +}) => { + const { t } = useTranslation(); -export const getServerSideProps: GetServerSideProps = async () => { + return ( + <> +
+ + {t`common:title`} + + +
+ + ); +}; + +export const getServerSideProps: GetServerSideProps = async ({ + locale, + locales, +}) => { const apolloClient = initializeApollo(); await apolloClient.query({ @@ -48,6 +60,9 @@ export const getServerSideProps: GetServerSideProps = async () => { return { props: { initialApolloState: apolloClient.cache.extract(), + _ns: await loadNamespaces(['common'], locale), + locale, + locales, }, }; };