Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rosetta i18n example #11841

Merged
merged 16 commits into from
Apr 21, 2020
Merged

Rosetta i18n example #11841

merged 16 commits into from
Apr 21, 2020

Conversation

StarpTech
Copy link
Contributor

@StarpTech StarpTech commented Apr 12, 2020

The most lightweight and elegant solution I have ever used with Next.js.

Examples with SSR, SSG, CSR and how users can be redirected to a default language like from / to en.

This example does not contain any dynamic language detection.

I really appreciate your feedback. 🙌

@ijjk
Copy link
Member

ijjk commented Apr 12, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.1s 10.2s ⚠️ +115ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..e3d8.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 917 B 917 B
link.html gzip 926 B 926 B
withRouter.html gzip 915 B 915 B
Overall change 2.76 kB 2.76 kB

Serverless Mode (Increase detected ⚠️)
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.4s 10.1s -291ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..e3d8.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js gzip 233 kB 233 kB ⚠️ +279 B
404.html gzip 1.32 kB 1.32 kB
hooks.html gzip 956 B 956 B
index.js gzip 233 kB 233 kB -45 B
link.js gzip 243 kB 243 kB -225 B
routerDirect.js gzip 241 kB 241 kB ⚠️ +368 B
withRouter.js gzip 241 kB 241 kB ⚠️ +48 B
Overall change 1.19 MB 1.19 MB ⚠️ +425 B

@ijjk
Copy link
Member

ijjk commented Apr 12, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.4s 10.5s ⚠️ +131ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..e3d8.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 917 B 917 B
link.html gzip 926 B 926 B
withRouter.html gzip 915 B 915 B
Overall change 2.76 kB 2.76 kB

Serverless Mode (Decrease detected ✓)
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.2s 11.4s ⚠️ +206ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..e3d8.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall decrease ✓
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js gzip 233 kB 233 kB -497 B
404.html gzip 1.32 kB 1.32 kB
hooks.html gzip 956 B 956 B
index.js gzip 233 kB 233 kB -278 B
link.js gzip 243 kB 243 kB -17 B
routerDirect.js gzip 241 kB 241 kB -72 B
withRouter.js gzip 241 kB 241 kB ⚠️ +19 B
Overall change 1.19 MB 1.19 MB -845 B

@ijjk
Copy link
Member

ijjk commented Apr 13, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.5s 10.3s -222ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..a4ac.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 925 B 925 B
link.html gzip 934 B 934 B
withRouter.html gzip 921 B 921 B
Overall change 2.78 kB 2.78 kB

Serverless Mode (Decrease detected ✓)
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.8s 11.1s ⚠️ +287ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..a4ac.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall decrease ✓
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js gzip 233 kB 233 kB -324 B
404.html gzip 1.33 kB 1.33 kB
hooks.html gzip 957 B 957 B
index.js gzip 233 kB 233 kB -207 B
link.js gzip 243 kB 243 kB ⚠️ +77 B
routerDirect.js gzip 241 kB 241 kB ⚠️ +123 B
withRouter.js gzip 241 kB 241 kB -68 B
Overall change 1.19 MB 1.19 MB -399 B

@ijjk
Copy link
Member

ijjk commented Apr 13, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.6s 10.4s -165ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..a4ac.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 925 B 925 B
link.html gzip 934 B 934 B
withRouter.html gzip 921 B 921 B
Overall change 2.78 kB 2.78 kB

Serverless Mode (Increase detected ⚠️)
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.5s 11.6s ⚠️ +74ms
nodeModulesSize 61 MB 61 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..a4ac.js gzip 10.2 kB 10.2 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.3 kB 56.3 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.78 kB 6.78 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.03 kB 2.03 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.86 kB 7.86 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.48 kB 1.48 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.28 kB 5.28 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles Overall increase ⚠️
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js gzip 233 kB 233 kB ⚠️ +168 B
404.html gzip 1.33 kB 1.33 kB
hooks.html gzip 957 B 957 B
index.js gzip 233 kB 233 kB -87 B
link.js gzip 243 kB 243 kB ⚠️ +65 B
routerDirect.js gzip 241 kB 241 kB -78 B
withRouter.js gzip 241 kB 241 kB ⚠️ +64 B
Overall change 1.19 MB 1.19 MB ⚠️ +132 B

Comment on lines 1 to 31
import Link from 'next/link'
import Head from 'next/head'
import useI18n from '../hooks/use-i18n'
import { contentLanguageMap } from '../lib/i18n'

const Contact = ({ lng }) => {
const i18n = useI18n(lng)

return (
<div>
<Head>
<meta http-equiv="content-language" content={contentLanguageMap[lng]} />
</Head>
<h1>{i18n.t('contact.email')}</h1>
<div>Current locale: {i18n.activeLocale}</div>
<Link href={{ pathname: '/contact', query: { lng: 'de' } }}>
<a>Change language SSR to 'de'</a>
</Link>
</div>
)
}

export async function getServerSideProps({ query }) {
return {
props: {
lng: query.lng || 'en', // OR detect default language based on header OR user setting
}, // will be passed to the page component as props
}
}

export default Contact
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this page to pages/[lng]/contact.js and use getStaticProps, there's no good use case for having a serverless function decide the language of the page if you can do that at build time 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right but it must not be a good use case. I want to demonstrate the different modes.

Copy link
Member

@lfades lfades Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer to demonstrate good use cases in examples always, rather than show the usage of some method, we have docs and learning lessons for that.

For this case getStaticProps is better.

Copy link
Contributor Author

@StarpTech StarpTech Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you get my point? I'd like to demonstrate that the i18n solution works in all modes CSR, SSG, SSR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it surely does, but you don't have to demonstrate it, instead you have to show the community the best way of using it 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth having 3 separate examples? Whichever you decide should be default behavior can be with-i18n and then you can have the two other mode be with-i18n-(csr|ssg).

While I understand and relate to both points, I do think as an official example, something should be as concise and as close to prod-ready as possible instead of forcing the user to figure out what's actually core/necessary.

I suggest with-i18n since no one will know what "rosetta" is when browsing the directory list ¯\(ツ)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfades I updated it. @lukeed that was my first idea too but there are other i18n solutions here. I renamed it to with-rosetta-i18n

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, then with-i18n-rosetta would be better for grouping 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ijjk
Copy link
Member

ijjk commented Apr 15, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.7s 10.7s ⚠️ +12ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 927 B 927 B
link.html gzip 936 B 936 B
withRouter.html gzip 923 B 923 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11s 11.4s ⚠️ +404ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 557 kB 557 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 557 kB 557 kB
link.js 594 kB 594 kB
routerDirect.js 586 kB 586 kB
withRouter.js 586 kB 586 kB
Overall change 2.89 MB 2.89 MB

@ijjk
Copy link
Member

ijjk commented Apr 15, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.6s 11.7s ⚠️ +75ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 927 B 927 B
link.html gzip 936 B 936 B
withRouter.html gzip 923 B 923 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 12.5s 12.3s -177ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 557 kB 557 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 557 kB 557 kB
link.js 594 kB 594 kB
routerDirect.js 586 kB 586 kB
withRouter.js 586 kB 586 kB
Overall change 2.89 MB 2.89 MB

@ijjk
Copy link
Member

ijjk commented Apr 15, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.1s 10.5s -567ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 927 B 927 B
link.html gzip 936 B 936 B
withRouter.html gzip 923 B 923 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.9s 11.8s -147ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 557 kB 557 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 557 kB 557 kB
link.js 594 kB 594 kB
routerDirect.js 586 kB 586 kB
withRouter.js 586 kB 586 kB
Overall change 2.89 MB 2.89 MB

@ijjk
Copy link
Member

ijjk commented Apr 15, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.9s 11.3s ⚠️ +411ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 927 B 927 B
link.html gzip 936 B 936 B
withRouter.html gzip 923 B 923 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.8s 11.6s -109ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 557 kB 557 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 557 kB 557 kB
link.js 594 kB 594 kB
routerDirect.js 586 kB 586 kB
withRouter.js 586 kB 586 kB
Overall change 2.89 MB 2.89 MB

@ijjk
Copy link
Member

ijjk commented Apr 15, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 9.8s 10.4s ⚠️ +676ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 927 B 927 B
link.html gzip 936 B 936 B
withRouter.html gzip 923 B 923 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.6s 10.4s -186ms
nodeModulesSize 55.5 MB 55.5 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..93a0.js gzip 10.3 kB 10.3 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 56.4 kB 56.4 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.78 kB 4.78 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.84 kB 6.84 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 51.5 kB 51.5 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.24 kB 1.24 kB
_error.js gzip 3.15 kB 3.15 kB
hooks.js gzip 664 B 664 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 279 B 279 B
withRouter.js gzip 278 B 278 B
Overall change 7.88 kB 7.88 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 594 B 594 B
_error.module.js gzip 2.08 kB 2.08 kB
hooks.module.js gzip 370 B 370 B
index.module.js gzip 212 B 212 B
link.module.js gzip 1.51 kB 1.51 kB
routerDirect..dule.js gzip 271 B 271 B
withRouter.m..dule.js gzip 270 B 270 B
Overall change 5.3 kB 5.3 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 557 kB 557 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 557 kB 557 kB
link.js 594 kB 594 kB
routerDirect.js 586 kB 586 kB
withRouter.js 586 kB 586 kB
Overall change 2.89 MB 2.89 MB

@StarpTech StarpTech requested a review from lfades April 16, 2020 10:25
@ijjk
Copy link
Member

ijjk commented Apr 20, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 9.2s 9.8s ⚠️ +644ms
nodeModulesSize 55.6 MB 55.6 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..5e5e.js gzip 10.3 kB 10.3 kB
framework.a1..NSE.txt gzip 220 B 220 B
framework.a1..NSE.txt gzip 220 B 220 B
framework.HASH.js gzip 39 kB 39 kB
Overall change 56.7 kB 56.7 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.79 kB 4.79 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.85 kB 6.85 kB
framework.HA..dule.js gzip 39 kB 39 kB
Overall change 51.4 kB 51.4 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.2 kB 26.2 kB
Overall change 26.2 kB 26.2 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.23 kB 1.23 kB
_error.js gzip 3.12 kB 3.12 kB
hooks.js gzip 663 B 663 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 280 B 280 B
withRouter.js gzip 278 B 278 B
Overall change 7.85 kB 7.85 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 598 B 598 B
_error.module.js gzip 2.09 kB 2.09 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.52 kB 1.52 kB
routerDirect..dule.js gzip 279 B 279 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.37 kB 5.37 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 929 B 929 B
link.html gzip 939 B 939 B
withRouter.html gzip 927 B 927 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 10.7s 10.6s -87ms
nodeModulesSize 55.6 MB 55.6 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..5e5e.js gzip 10.3 kB 10.3 kB
framework.a1..NSE.txt gzip 220 B 220 B
framework.a1..NSE.txt gzip 220 B 220 B
framework.HASH.js gzip 39 kB 39 kB
Overall change 56.7 kB 56.7 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.79 kB 4.79 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.85 kB 6.85 kB
framework.HA..dule.js gzip 39 kB 39 kB
Overall change 51.4 kB 51.4 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.2 kB 26.2 kB
Overall change 26.2 kB 26.2 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.23 kB 1.23 kB
_error.js gzip 3.12 kB 3.12 kB
hooks.js gzip 663 B 663 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 280 B 280 B
withRouter.js gzip 278 B 278 B
Overall change 7.85 kB 7.85 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 598 B 598 B
_error.module.js gzip 2.09 kB 2.09 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.52 kB 1.52 kB
routerDirect..dule.js gzip 279 B 279 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.37 kB 5.37 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 558 kB 558 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 558 kB 558 kB
link.js 595 kB 595 kB
routerDirect.js 587 kB 587 kB
withRouter.js 587 kB 587 kB
Overall change 2.89 MB 2.89 MB

@ijjk
Copy link
Member

ijjk commented Apr 20, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.6s 12.2s ⚠️ +566ms
nodeModulesSize 55.6 MB 55.6 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..5e5e.js gzip 10.3 kB 10.3 kB
framework.a1..NSE.txt gzip 220 B 220 B
framework.a1..NSE.txt gzip 220 B 220 B
framework.HASH.js gzip 39 kB 39 kB
Overall change 56.7 kB 56.7 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.79 kB 4.79 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.85 kB 6.85 kB
framework.HA..dule.js gzip 39 kB 39 kB
Overall change 51.4 kB 51.4 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.2 kB 26.2 kB
Overall change 26.2 kB 26.2 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.23 kB 1.23 kB
_error.js gzip 3.12 kB 3.12 kB
hooks.js gzip 663 B 663 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 280 B 280 B
withRouter.js gzip 278 B 278 B
Overall change 7.85 kB 7.85 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 598 B 598 B
_error.module.js gzip 2.09 kB 2.09 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.52 kB 1.52 kB
routerDirect..dule.js gzip 279 B 279 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.37 kB 5.37 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 929 B 929 B
link.html gzip 939 B 939 B
withRouter.html gzip 927 B 927 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 12.4s 12.1s -258ms
nodeModulesSize 55.6 MB 55.6 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..5e5e.js gzip 10.3 kB 10.3 kB
framework.a1..NSE.txt gzip 220 B 220 B
framework.a1..NSE.txt gzip 220 B 220 B
framework.HASH.js gzip 39 kB 39 kB
Overall change 56.7 kB 56.7 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.79 kB 4.79 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.85 kB 6.85 kB
framework.HA..dule.js gzip 39 kB 39 kB
Overall change 51.4 kB 51.4 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.2 kB 26.2 kB
Overall change 26.2 kB 26.2 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.23 kB 1.23 kB
_error.js gzip 3.12 kB 3.12 kB
hooks.js gzip 663 B 663 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 280 B 280 B
withRouter.js gzip 278 B 278 B
Overall change 7.85 kB 7.85 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 598 B 598 B
_error.module.js gzip 2.09 kB 2.09 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.52 kB 1.52 kB
routerDirect..dule.js gzip 279 B 279 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.37 kB 5.37 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 558 kB 558 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 558 kB 558 kB
link.js 595 kB 595 kB
routerDirect.js 587 kB 587 kB
withRouter.js 587 kB 587 kB
Overall change 2.89 MB 2.89 MB

@janus-reith
Copy link

@StarpTech With the latest changes you pass the lngDict per page to the useI18n hook.
I see two issues with that:

  • This creates additional verbosity per page to use it
  • This destroys the advantage you could have with a simple hook:
    It seems like if you have some other component down the tree which should use localized strings, you would need to pass the strings all down in order to be able to use them?

What do you think of the suggestion I made before to just pass them in _app.js? Less verbose, and you could just use the hook everywhere.
You're already using your <I18n> component there and could just pass it as prop if present on pageProps.
While getStaticProps is working on a per page basis, the props it passes will still be available as pageProps on _app.js for that page.

@StarpTech
Copy link
Contributor Author

Good point, I'll address it.

@ijjk
Copy link
Member

ijjk commented Apr 21, 2020

Stats from current PR

Default Server Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 11.9s 11.7s -181ms
nodeModulesSize 55.6 MB 55.6 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..5e5e.js gzip 10.3 kB 10.3 kB
framework.a1..NSE.txt gzip 220 B 220 B
framework.a1..NSE.txt gzip 220 B 220 B
framework.HASH.js gzip 39 kB 39 kB
Overall change 56.7 kB 56.7 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.79 kB 4.79 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.85 kB 6.85 kB
framework.HA..dule.js gzip 39 kB 39 kB
Overall change 51.4 kB 51.4 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.2 kB 26.2 kB
Overall change 26.2 kB 26.2 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.23 kB 1.23 kB
_error.js gzip 3.12 kB 3.12 kB
hooks.js gzip 663 B 663 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 280 B 280 B
withRouter.js gzip 278 B 278 B
Overall change 7.85 kB 7.85 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 598 B 598 B
_error.module.js gzip 2.09 kB 2.09 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.52 kB 1.52 kB
routerDirect..dule.js gzip 279 B 279 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.37 kB 5.37 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Rendered Page Sizes
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
index.html gzip 928 B 928 B
link.html gzip 938 B 938 B
withRouter.html gzip 925 B 925 B
Overall change 2.79 kB 2.79 kB

Serverless Mode
General
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
buildDuration 12.3s 12.5s ⚠️ +200ms
nodeModulesSize 55.6 MB 55.6 MB
Client Bundles (main, webpack, commons)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.js gzip 6.25 kB 6.25 kB
webpack-HASH.js gzip 746 B 746 B
de003c3a9d30..5e5e.js gzip 10.3 kB 10.3 kB
framework.a1..NSE.txt gzip 220 B 220 B
framework.a1..NSE.txt gzip 220 B 220 B
framework.HASH.js gzip 39 kB 39 kB
Overall change 56.7 kB 56.7 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
main-HASH.module.js gzip 4.79 kB 4.79 kB
webpack-HASH..dule.js gzip 746 B 746 B
de003c3a9d30..dule.js gzip 6.85 kB 6.85 kB
framework.HA..dule.js gzip 39 kB 39 kB
Overall change 51.4 kB 51.4 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
polyfills-HASH.js gzip 26.2 kB 26.2 kB
Overall change 26.2 kB 26.2 kB
Client Pages
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.js gzip 1.23 kB 1.23 kB
_error.js gzip 3.12 kB 3.12 kB
hooks.js gzip 663 B 663 B
index.js gzip 222 B 222 B
link.js gzip 2.06 kB 2.06 kB
routerDirect.js gzip 280 B 280 B
withRouter.js gzip 278 B 278 B
Overall change 7.85 kB 7.85 kB
Client Pages Modern
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_app.module.js gzip 598 B 598 B
_error.module.js gzip 2.09 kB 2.09 kB
hooks.module.js gzip 383 B 383 B
index.module.js gzip 223 B 223 B
link.module.js gzip 1.52 kB 1.52 kB
routerDirect..dule.js gzip 279 B 279 B
withRouter.m..dule.js gzip 278 B 278 B
Overall change 5.37 kB 5.37 kB
Client Build Manifests
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_buildManifest.js gzip 61 B 61 B
_buildManife..dule.js gzip 61 B 61 B
Overall change 122 B 122 B
Serverless bundles
zeit/next.js canary StarpTech/next.js rosetta_i18n_example Change
_error.js 558 kB 558 kB
404.html 4.18 kB 4.18 kB
hooks.html 3.81 kB 3.81 kB
index.js 558 kB 558 kB
link.js 595 kB 595 kB
routerDirect.js 587 kB 587 kB
withRouter.js 587 kB 587 kB
Overall change 2.89 MB 2.89 MB

Copy link
Member

@lfades lfades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StarpTech Thank you for the PR, nice work 💯

@lfades lfades merged commit d28ad88 into vercel:canary Apr 21, 2020
@StarpTech
Copy link
Contributor Author

@lfades thanks for the fixes.

@rogerbramon
Copy link

rogerbramon commented Aug 9, 2020

Thanks @StarpTech for this nice example! Not sure if it's the right place to mention it, let me know otherwise.

I was trying out your example and I found a potential issue with Links.

I noticed that the link to /de on index.js causes a full page reload. I'm a newbie on Next world but I assume it's because we should treat it as dynamic route: <Link href="/[lng]" as="/de">. However, using dynamic routing only the current language gets updated but not the lngDict. Thus, the whole page keeps in English.

I'm able to get the right behavior replacing activeDict by lngDict on lib/i18n.js line 32:
i18n.set(locale, lngDict)

Does it make sense?

I'm also wondering on the same useEffect:

  • Do we miss a setActiveDict(lngDict)?
  • Why a force rerender (setTick((tick) => tick + 1)) is needed?

Thanks!

@StarpTech
Copy link
Contributor Author

Hi @rogerbramon you're right I found couple of issues. No idea why they didn't arrive earlier. I created a PR #16023

@StarpTech
Copy link
Contributor Author

Why a force rerender (setTick((tick) => tick + 1)) is needed

In order to update the view on locale change.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants