Skip to content

Commit

Permalink
Create _document.js to include current language in HTML tag (vercel#1…
Browse files Browse the repository at this point in the history
…6360)

* Create _document.js

 Includes the lang attribute with current language inside the <html> tag.

* Lint fix

Co-authored-by: Luis Alvarez D <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and ijjk committed Sep 2, 2020
1 parent 1dd1f70 commit deb40ea
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/with-i18n-rosetta/pages/_document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Document, { Html, Head, Main, NextScript } from 'next/document'

class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)

return { ...initialProps, lang: ctx.query.lng }
}

render() {
return (
<Html lang={this.props.lang}>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}

export default MyDocument

0 comments on commit deb40ea

Please sign in to comment.