You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/index.js
+30-5
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@ import Head from 'next/head'
2
2
importHeaderfrom'@components/Header'
3
3
importFooterfrom'@components/Footer'
4
4
5
-
exportdefaultfunctionHome(){
5
+
exportdefaultfunctionHome({locale}){
6
6
return(
7
7
<divclassName="container">
8
8
<Head>
@@ -12,9 +12,31 @@ export default function Home() {
12
12
13
13
<main>
14
14
<Headertitle="Welcome to my app!"/>
15
-
<p>In v3 of the next plugin, the <code>NEXT_LOCALE</code> and the `Accept-Language` header is not detected. This is fixed in v4. The workaround is manually detecting if the cookie and header exist and changing the behavior of your site in consequence.</p>
16
15
<pclassName="description">
17
-
<strong>Locale in url</strong>
16
+
<strong>Locale: {locale}</strong>
17
+
</p>
18
+
<p>(you should see it appended to this site's url if your browser does not use the default one, <code>en</code> )</p>
19
+
<p>In v3 of the next plugin, the <code>NEXT_LOCALE</code> and the `Accept-Language` header is not detected. This is fixed in v4. The workaround is manually detecting if the cookie and header exist and changing the behavior of your site in consequence.</p>
20
+
<ahref="https://github.com/netlify/netlify-plugin-nextjs/issues/788#issue-1050456600">See GitHub Issue for full context</a>
21
+
<p>
22
+
Test steps for this page:
23
+
<ol>
24
+
<li>
25
+
Change your default browser language to french. In Chrome: language to french (Settings ->Advanced->Language->AddFrench->Movetotop)
26
+
</li>
27
+
<li>
28
+
Refresh this page, you should see it appended with <strong>/fr</strong>, and the text on the page should change to show <strong>fr</strong>
29
+
</li>
30
+
<li>
31
+
Open the dev tools to the console
32
+
</li>
33
+
<li>
34
+
Enter <strong>document.cookie="NEXT_LOCALE=es"</strong>
35
+
</li>
36
+
<li>
37
+
Refresh this page. You should see it appended with <strong>/es</strong>
38
+
</li>
39
+
</ol>
18
40
</p>
19
41
</main>
20
42
@@ -25,14 +47,17 @@ export default function Home() {
0 commit comments