-
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.
fix: fix hashing algo and locale value hydration (#16692)
- Fix hashing algo for extraction so it's the same as babel config - Fix locale persistence issue fix #16689
- Loading branch information
Showing
6 changed files
with
63 additions
and
13 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"11754": "An example app integrating React Intl with Next.js", | ||
"65a8e": "Hello, World!", | ||
"8cf04": "Home", | ||
"8f7f4": "About", | ||
"9c817": "React Intl Next.js Example" | ||
"AvQcw8": "React Intl Next.js Example", | ||
"N015Sp": "Hello, World!", | ||
"ejEGdx": "Home", | ||
"fnfXnF": "An example app integrating React Intl with Next.js", | ||
"g5pX+a": "About" | ||
} |
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 @@ | ||
{ | ||
"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" | ||
"AvQcw8": "Un exemple d'application intégrant React Intl avec Next.js", | ||
"N015Sp": "Bonjour le monde!", | ||
"ejEGdx": "Accueil", | ||
"fnfXnF": "À propos de nous", | ||
"g5pX+a": "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
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,46 @@ | ||
import Document, { | ||
Html, | ||
Head, | ||
Main, | ||
NextScript, | ||
DocumentContext, | ||
} from 'next/document'; | ||
|
||
interface Props { | ||
locale: string; | ||
lang: string; | ||
nonce: string; | ||
} | ||
|
||
class MyDocument extends Document<Props> { | ||
static async getInitialProps(ctx: DocumentContext) { | ||
const {req} = ctx; | ||
const initialProps = await Document.getInitialProps(ctx); | ||
return { | ||
...initialProps, | ||
locale: (req as any).locale || 'en', | ||
lang: ((req as any).locale || 'en').split('-')[0], | ||
nonce: (req as any).nonce, | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Html lang={this.props.lang}> | ||
<Head /> | ||
<body> | ||
<script | ||
nonce={this.props.nonce} | ||
dangerouslySetInnerHTML={{ | ||
__html: `window.LOCALE="${this.props.locale}"`, | ||
}} | ||
></script> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
); | ||
} | ||
} | ||
|
||
export default MyDocument; |
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