From deb40ea0937d8548e803354bce93f459c8bcf41b Mon Sep 17 00:00:00 2001 From: John Doe <47635466+seosmmbusiness@users.noreply.github.com> Date: Wed, 2 Sep 2020 17:50:08 +0300 Subject: [PATCH] Create _document.js to include current language in HTML tag (#16360) * Create _document.js Includes the lang attribute with current language inside the tag. * Lint fix Co-authored-by: Luis Alvarez D Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- examples/with-i18n-rosetta/pages/_document.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/with-i18n-rosetta/pages/_document.js diff --git a/examples/with-i18n-rosetta/pages/_document.js b/examples/with-i18n-rosetta/pages/_document.js new file mode 100644 index 0000000000000..7d2b7c79119ab --- /dev/null +++ b/examples/with-i18n-rosetta/pages/_document.js @@ -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 ( + + + +
+ + + + ) + } +} + +export default MyDocument