Skip to content

Commit

Permalink
feat(i18n): try reading translations files in homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKandelborg committed Oct 22, 2020
1 parent bb08046 commit a1d7ec0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion components/UI/Pages/Home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ type IHomePageProps = PageProps
const { Grid } = MUI

const HomePage: React.FC<IHomePageProps> = (props) => {
const { config } = props
const { config, translation } = props

const classes = homePageStyles()

return (
<>
<AnimatePresence
exitBeforeEnter
presenceAffectsLayout
onExitComplete={() => handleExitComplete()}>
<TitleWithDivider key="home-title" variant="h1" text={config.title} />
Expand All @@ -34,6 +35,7 @@ const HomePage: React.FC<IHomePageProps> = (props) => {
src="/images/TRUE-logo/TRUE-logo-social-large-small-blue.png"
alt="TRUE Framework Logo Header"
/>
<h1>{translation![0].title}</h1>
<br />
<br />
<SectionWhyUseTrue />
Expand Down
5 changes: 3 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PageSEO from '@components/HoC/SEO/Page'
import HomePage from '@components/UI/Pages/Home/HomePage'
import getSanityConfig from '@util/api/calls/getSanityConfig'
import resolveTranslationFiles from '@util/i18n/resolveTranslationFiles'
import { TSupportedLanguages } from 'i18n/Languages'
import { GetStaticProps, InferGetStaticPropsType } from 'next'
import { PageProps } from 'PageProps'

Expand All @@ -17,8 +18,8 @@ export const getStaticProps: GetStaticProps<PageProps> = async (ctx) => {
* To access keys in the file, use object notation
*/
const translation = resolveTranslationFiles({
locale: ctx.locale || error,
locales: ctx.locales || [error],
locale: (ctx.locale as TSupportedLanguages) || error,
locales: (ctx.locales as TSupportedLanguages[]) || [error],
namespaces: ['homePage', 'test']
})

Expand Down

0 comments on commit a1d7ec0

Please sign in to comment.