forked from i18next/next-i18next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (38 loc) · 951 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
42
43
44
import React from 'react'
import PropTypes from 'prop-types'
import { i18n, Link, withNamespaces } from '../i18n'
import Title from '../components/Title'
import Footer from '../components/Footer'
class Homepage extends React.Component {
static async getInitialProps() {
return {
namespacesRequired: ['common', 'footer'],
}
}
render() {
const { t } = this.props
return (
<React.Fragment>
<Title />
<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>
<Footer />
</React.Fragment>
)
}
}
Homepage.propTypes = {
t: PropTypes.func.isRequired,
}
export default withNamespaces('common')(Homepage)