Skip to content

Commit

Permalink
Merge branch 'master' of github.com:i18next/react-i18next
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed Oct 30, 2018
2 parents 12014d4 + f9286f6 commit 393aad9
Show file tree
Hide file tree
Showing 3 changed files with 26 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
4 changes: 4 additions & 0 deletions example/nextjs/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ export default withI18next(['home', 'common'])(({ t, initialI18nStore, ...rest }
<Link href="/page2">
<a>{t('link.gotoPage2')}</a>
</Link>
<br />
<Link href="/page3">
<a>{t('link.gotoPage3')}</a>
</Link>
</div>
));
12 changes: 12 additions & 0 deletions example/nextjs/pages/page3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// a page not using i18next - no hoc - not t function
import React from 'react';
import Link from 'next/link';

export default () => (
<div>
<h1>Hello Page 3</h1>
<Link href="/">
<a>back</a>
</Link>
</div>
);

0 comments on commit 393aad9

Please sign in to comment.