-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
361 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const NextI18Next = require('next-i18next').default | ||
const { localeSubpaths } = require('next/config').default().publicRuntimeConfig | ||
const path = require('path') | ||
|
||
module.exports = new NextI18Next({ | ||
otherLanguages: ['fr'], | ||
localeSubpaths, | ||
localePath: path.resolve('./public/static/locales') | ||
}) |
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,2 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> |
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,14 @@ | ||
const { nextI18NextRewrites } = require('next-i18next/rewrites') | ||
|
||
const localeSubpaths = { | ||
fr: 'fr', | ||
en: 'eng', | ||
} | ||
|
||
module.exports = { | ||
rewrites: async () => nextI18NextRewrites(localeSubpaths), | ||
publicRuntimeConfig: { | ||
localeSubpaths, | ||
}, | ||
poweredByHeader: false, | ||
} |
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 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,25 @@ | ||
import "../styles/globals.css"; | ||
|
||
import React from "react"; | ||
import App, { AppProps } from "next/app"; | ||
import Head from "next/head"; | ||
|
||
import { appWithTranslation } from "../i18n"; | ||
|
||
function MyApp({ Component, pageProps }: AppProps) { | ||
return ( | ||
<> | ||
<Head> | ||
<title>Example</title> | ||
{/* <link rel='icon' type='image/png' href='/favicon.png' /> */} | ||
</Head> | ||
<Component {...pageProps} /> | ||
</> | ||
); | ||
} | ||
|
||
MyApp.getInitialProps = async (appContext) => ({ | ||
...(await App.getInitialProps(appContext)), | ||
}); | ||
|
||
export default appWithTranslation(MyApp); |
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,34 @@ | ||
import PropTypes from 'prop-types' | ||
import { withTranslation } from '../i18n' | ||
|
||
const Error = ({ statusCode, t }) => ( | ||
<p> | ||
{statusCode | ||
? t('error-with-status', { statusCode }) | ||
: t('error-without-status')} | ||
</p> | ||
) | ||
|
||
Error.getInitialProps = async ({ res, err }) => { | ||
let statusCode = null | ||
if (res) { | ||
({ statusCode } = res) | ||
} else if (err) { | ||
({ statusCode } = err) | ||
} | ||
return { | ||
namespacesRequired: ['common'], | ||
statusCode, | ||
} | ||
} | ||
|
||
Error.defaultProps = { | ||
statusCode: null, | ||
} | ||
|
||
Error.propTypes = { | ||
statusCode: PropTypes.number, | ||
t: PropTypes.func.isRequired, | ||
} | ||
|
||
export default withTranslation('common')(Error) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import styles from "../styles/Home.module.css"; | ||
import PropTypes from 'prop-types' | ||
|
||
import React from "react"; | ||
import { TFunction } from "next-i18next"; | ||
import { Link, i18n, withTranslation } from "../i18n"; | ||
|
||
function Page({ t }: { readonly t: TFunction }) { | ||
return ( | ||
<div className={styles.container}> | ||
{t("language")} | ||
|
||
<button | ||
className={styles.btn1} | ||
type="button" | ||
onClick={() => | ||
i18n.changeLanguage(i18n.language === "en" ? "fr" : "en") | ||
} | ||
> | ||
{t("change-language")} | ||
</button> | ||
</div> | ||
); | ||
} | ||
|
||
Page.getInitialProps = async () => ({ | ||
namespacesRequired: ['common'], | ||
}); | ||
|
||
export default withTranslation('common')(Page); |
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,4 @@ | ||
{ | ||
"change-language": "Fr", | ||
"language": "Language" | ||
} |
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,4 @@ | ||
{ | ||
"change-language": "En", | ||
"language": "Langage" | ||
} |
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,29 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"esnext" | ||
], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": false, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve" | ||
}, | ||
"include": [ | ||
"next-env.d.ts", | ||
"**/*.ts", | ||
"**/*.tsx" | ||
, "i18n.js", "pages/_error.js" ], | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
Oops, something went wrong.