Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
db1ee2e1
Commit
db1ee2e1
authored
Jun 16, 2017
by
Felipe
Committed by
Tim Neutkens
Jun 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Intl API polyfill in with-react-intl example (#2283)
* Add Intl API polyfill in with-react-intl example * fix linting
parent
6303d19a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
_document.js
examples/with-react-intl/pages/_document.js
+6
-1
No files found.
examples/with-react-intl/pages/_document.js
View file @
db1ee2e1
...
@@ -5,19 +5,24 @@ import Document, {Head, Main, NextScript} from 'next/document'
...
@@ -5,19 +5,24 @@ import Document, {Head, Main, NextScript} from 'next/document'
export
default
class
IntlDocument
extends
Document
{
export
default
class
IntlDocument
extends
Document
{
static
async
getInitialProps
(
context
)
{
static
async
getInitialProps
(
context
)
{
const
props
=
await
super
.
getInitialProps
(
context
)
const
props
=
await
super
.
getInitialProps
(
context
)
const
{
req
:
{
localeDataScript
}}
=
context
const
{
req
:
{
locale
,
locale
DataScript
}}
=
context
return
{
return
{
...
props
,
...
props
,
locale
,
localeDataScript
localeDataScript
}
}
}
}
render
()
{
render
()
{
// Polyfill Intl API for older browsers
const
polyfill
=
`https://cdn.polyfill.io/v2/polyfill.min.js?features=Intl.~locale.
${
this
.
props
.
locale
}
`
return
(
return
(
<
html
>
<
html
>
<
Head
/>
<
Head
/>
<
body
>
<
body
>
<
Main
/>
<
Main
/>
<
script
src
=
{
polyfill
}
/
>
<
script
<
script
dangerouslySetInnerHTML
=
{{
dangerouslySetInnerHTML
=
{{
__html
:
this
.
props
.
localeDataScript
__html
:
this
.
props
.
localeDataScript
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment