2017-04-30 14:35:07 +00:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { I18nextProvider } from 'react-i18next'
|
|
|
|
import startI18n from '../tools/startI18n'
|
|
|
|
import { getTranslation } from '../tools/translationHelpers'
|
|
|
|
import Title from '../components/Title'
|
2017-08-13 00:28:20 +00:00
|
|
|
import Post from '../components/Post'
|
2017-04-30 14:35:07 +00:00
|
|
|
|
2017-05-17 17:41:54 +00:00
|
|
|
// get language from query parameter or url path
|
|
|
|
const lang = 'id'
|
|
|
|
|
2017-04-30 14:35:07 +00:00
|
|
|
export default class Homepage extends Component {
|
|
|
|
static async getInitialProps () {
|
2017-08-13 00:28:20 +00:00
|
|
|
const translations = await getTranslation(
|
|
|
|
lang,
|
|
|
|
['common', 'namespace1'],
|
|
|
|
'http://localhost:3000/static/locales/'
|
|
|
|
)
|
2017-04-30 14:35:07 +00:00
|
|
|
|
|
|
|
return { translations }
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor (props) {
|
|
|
|
super(props)
|
|
|
|
|
2017-05-17 17:41:54 +00:00
|
|
|
this.i18n = startI18n(props.translations, lang)
|
2017-04-30 14:35:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render (props) {
|
|
|
|
return (
|
|
|
|
<I18nextProvider i18n={this.i18n}>
|
2017-08-13 00:28:20 +00:00
|
|
|
<div>
|
|
|
|
<Title />
|
|
|
|
<Post />
|
|
|
|
</div>
|
2017-06-13 06:57:07 +00:00
|
|
|
</I18nextProvider>
|
2017-04-30 14:35:07 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|