-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use i18next plugin system to get the i18next instance.
- Loading branch information
Showing
46 changed files
with
408 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { appWithTranslation } from 'next-i18next'; | ||
import nextI18NextConfig from '../next-i18next.config'; | ||
|
||
const MyApp = ({ Component, pageProps }) => <Component {...pageProps} />; | ||
|
||
// https://github.com/i18next/next-i18next#unserialisable-configs | ||
export default appWithTranslation(MyApp, nextI18NextConfig); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
|
||
import { useTranslation, Trans } from 'next-i18next'; | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
|
||
import { Header } from '../components/Header'; | ||
import { Footer } from '../components/Footer'; | ||
|
||
const Homepage = () => { | ||
const router = useRouter(); | ||
const { t } = useTranslation('common'); | ||
|
||
return ( | ||
<> | ||
<main> | ||
<Header heading={t('h1')} title={t('title')} /> | ||
<div style={{ display: 'inline-flex', width: '90%' }}> | ||
<div style={{ width: '50%' }}> | ||
<h3 style={{ minHeight: 70 }}>{t('blog.optimized.question')}</h3> | ||
<p> | ||
<Trans i18nKey="blog.optimized.answer"> | ||
Then you may have a look at{' '} | ||
<a href="https://locize.com/blog/next-i18next/">this blog post</a>. | ||
</Trans> | ||
</p> | ||
<a href="https://locize.com/blog/next-i18next/"> | ||
<img | ||
style={{ width: '50%' }} | ||
src="https://locize.com/blog/next-i18next/next-i18next.jpg" | ||
/> | ||
</a> | ||
</div> | ||
<div style={{ width: '50%' }}> | ||
<h3 style={{ minHeight: 70 }}>{t('blog.ssg.question')}</h3> | ||
<p> | ||
<Trans i18nKey="blog.ssg.answer"> | ||
Then you may have a look at{' '} | ||
<a href="https://locize.com/blog/next-i18n-static/">this blog post</a>. | ||
</Trans> | ||
</p> | ||
<a href="https://locize.com/blog/next-i18n-static/"> | ||
<img | ||
style={{ width: '50%' }} | ||
src="https://locize.com/blog/next-i18n-static/title.jpg" | ||
/> | ||
</a> | ||
</div> | ||
</div> | ||
<hr style={{ marginTop: 20, width: '90%' }} /> | ||
<div> | ||
<Link href="/" locale={router.locale === 'en' ? 'de' : 'en'}> | ||
<button> | ||
{t('change-locale', { changeTo: router.locale === 'en' ? 'de' : 'en' })} | ||
</button> | ||
</Link> | ||
<Link href="/second-page"> | ||
<button type="button">{t('to-second-page')}</button> | ||
</Link> | ||
</div> | ||
</main> | ||
<Footer /> | ||
</> | ||
); | ||
}; | ||
|
||
export const getStaticProps = async ({ locale }) => ({ | ||
props: { | ||
...(await serverSideTranslations(locale, ['common', 'footer'])), | ||
}, | ||
}); | ||
|
||
export default Homepage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Link from 'next/link'; | ||
|
||
import { useTranslation } from 'next-i18next'; | ||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; | ||
|
||
import { Header } from '../components/Header'; | ||
import { Footer } from '../components/Footer'; | ||
|
||
const SecondPage = () => { | ||
const { t } = useTranslation('second-page'); | ||
|
||
return ( | ||
<> | ||
<main> | ||
<Header heading={t('h1')} title={t('title')} /> | ||
<Link href="/"> | ||
<button type="button">{t('back-to-home')}</button> | ||
</Link> | ||
</main> | ||
<Footer /> | ||
</> | ||
); | ||
}; | ||
|
||
export const getStaticProps = async ({ locale }) => ({ | ||
props: { | ||
...(await serverSideTranslations(locale, ['second-page', 'footer'])), | ||
}, | ||
}); | ||
|
||
export default SecondPage; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...i18next-v11/public/locales/en/footer.json → ...i18next-v13/public/locales/en/footer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"description": "This is a non-page component that requires its own namespace" | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.