Skip to content

Commit

Permalink
Fix default lang bug when React tree doesn't contain withI18next
Browse files Browse the repository at this point in the history
  • Loading branch information
isaachinman committed Oct 28, 2018
1 parent 19f5f3f commit 3c20461
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion example/nextjs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ if (enableSubpaths) {
// Warning: Did not expect server HTML to contain a <h1> in <div>.
// not sure - did neither find something wrong - nor seems the warning to make sense
export default class MyApp extends App {

static async getInitialProps({ ctx }) {
return {
initialLanguage: ctx.req.language ?
ctx.req.language : translation.defaultLanguage
};
};

render() {
const { Component, pageProps } = this.props;
const { Component, pageProps, initialLanguage } = this.props;

return (
<Container>
Expand All @@ -41,6 +49,7 @@ export default class MyApp extends App {
ns="common"
i18n={(pageProps && pageProps.i18n) || i18n}
wait={process.browser}
initialLanguage={initialLanguage}
>
{t => (
<React.Fragment>
Expand Down

0 comments on commit 3c20461

Please sign in to comment.