forked from i18next/next-i18next
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
41 lines (35 loc) · 913 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react'
import PropTypes from 'prop-types'
import { i18n, Link, withTranslation } from '../i18n'
import Header from '../components/Header'
import Footer from '../components/Footer'
const Homepage = ({ t }) => (
<React.Fragment>
<main>
<Header title={t('h1')} />
<div>
<button
type='button'
onClick={() => i18n.changeLanguage(i18n.language === 'en' ? 'de' : 'en')}
>
{t('change-locale')}
</button>
<Link href='/second-page'>
<button
type='button'
>
{t('to-second-page')}
</button>
</Link>
</div>
</main>
<Footer />
</React.Fragment>
)
Homepage.getInitialProps = async () => ({
namespacesRequired: ['common', 'footer'],
})
Homepage.propTypes = {
t: PropTypes.func.isRequired,
}
export default withTranslation('common')(Homepage)