-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade react-intl workflow in example
- Loading branch information
Showing
24 changed files
with
340 additions
and
328 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,10 @@ | ||
{ | ||
"presets": ["next/babel"], | ||
"plugins": [ | ||
["babel-plugin-react-intl", { | ||
"ast": true, | ||
"idInterpolationPattern": "[sha512:contenthash:base64:6]", | ||
"extractFromFormatMessageCall": true | ||
}] | ||
] | ||
} |
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 |
---|---|---|
|
@@ -33,3 +33,4 @@ yarn-error.log* | |
|
||
# vercel | ||
.vercel | ||
compiled-lang |
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,3 @@ | ||
{ | ||
"editor.formatOnSave": true | ||
} |
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,28 @@ | ||
import * as React from 'react'; | ||
import {useIntl} from 'react-intl'; | ||
import Head from 'next/head'; | ||
import Nav from './Nav'; | ||
|
||
export default function Layout({title, children}) { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<div> | ||
<Head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title> | ||
{title || | ||
intl.formatMessage({ | ||
defaultMessage: 'React Intl Next.js Example', | ||
})} | ||
</title> | ||
</Head> | ||
|
||
<header> | ||
<Nav /> | ||
</header> | ||
|
||
{children} | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"title": "React Intl Next.js Example", | ||
"nav.home": "Home", | ||
"nav.about": "About", | ||
"description": "An example app integrating React Intl with Next.js", | ||
"greeting": "Hello, World!" | ||
"11754": "An example app integrating React Intl with Next.js", | ||
"65a8e": "Hello, World!", | ||
"8cf04": "Home", | ||
"8f7f4": "About", | ||
"9c817": "React Intl Next.js Example" | ||
} |
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,7 +1,7 @@ | ||
{ | ||
"title": "React Intl Next.js Exemple", | ||
"nav.home": "Accueil", | ||
"nav.about": "À propos de nous", | ||
"description": "Un exemple d'application intégrant React Intl avec Next.js", | ||
"greeting": "Bonjour le monde!" | ||
"11754": "Un exemple d'application intégrant React Intl avec Next.js", | ||
"65a8e": "Bonjour le monde!", | ||
"8cf04": "Accueil", | ||
"8f7f4": "À propos de nous", | ||
"9c817": "React Intl Next.js Exemple" | ||
} |
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 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
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 * as React from 'react'; | ||
import {IntlProvider} from 'react-intl'; | ||
import {polyfill} from '../polyfills'; | ||
import App from 'next/app'; | ||
|
||
function MyApp({Component, pageProps, locale, messages}) { | ||
return ( | ||
<IntlProvider locale={locale} messages={messages}> | ||
<Component {...pageProps} /> | ||
</IntlProvider> | ||
); | ||
} | ||
|
||
const getInitialProps: typeof App.getInitialProps = async appContext => { | ||
const { | ||
ctx: {req}, | ||
} = appContext; | ||
const locale = (req as any)?.locale ?? 'en'; | ||
const messages = (req as any)?.messages ?? {}; | ||
const [appProps] = await Promise.all([ | ||
polyfill(locale), | ||
App.getInitialProps(appContext), | ||
]); | ||
|
||
return {...appProps, locale, messages}; | ||
}; | ||
|
||
MyApp.getInitialProps = getInitialProps; | ||
|
||
export default MyApp; |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
import * as React from 'react'; | ||
import {FormattedRelativeTime, useIntl} from 'react-intl'; | ||
import Layout from '../components/Layout'; | ||
|
||
export default function About() { | ||
const intl = useIntl(); | ||
return ( | ||
<Layout title={intl.formatMessage({defaultMessage: 'About'})}> | ||
<p> | ||
<FormattedRelativeTime numeric="auto" value={1} unit="hour" /> | ||
</p> | ||
</Layout> | ||
); | ||
} |
Oops, something went wrong.