valstu / korona-info

Suomen koronavirus-tartuntatilanne
MIT License
67 stars 19 forks source link

Added localisation / next-i18next support #13

Closed jonijuup closed 4 years ago

jonijuup commented 4 years ago

Also included some of the work done by @albacoretuna on another PR (didn't notice their work until I was done with mine). Feel free to use or dismiss.

Used https://github.com/isaachinman/next-i18next for translations.

vercel[bot] commented 4 years ago

This pull request is being automatically deployed with ZEIT Now (learn more). To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/valstu/korona/1492y4qsw ✅ Preview: https://korona-git-fork-jonijuup-master.valstu.now.sh

albacoretuna commented 4 years ago

Good job! 

Thanks for integrating my changes. It's more sophisticated than what I was doing. 

Could you make it work? The deployed preview fails to load. 

jonijuup commented 4 years ago

Good job!  Thanks for integrating my changes. It's more sophisticated than what I was doing.  Could you make it work? The deployed preview fails to load.

Good point, didn't see that. Maybe @valstu can paste some information from logs to have a tip about what's failing. 🤔

albacoretuna commented 4 years ago

It's unfortunate that such a common use case requires opting out of the built in next server :| 

But you have gone a long way to make it work locally, hopefully with the logs it can be fixed easily. 

valstu commented 4 years ago
[GET] /favicon.ico
20:34:53:15
2020-03-14T18:34:53.568Z    undefined   ERROR   Uncaught Exception  {"errorType":"Error","errorMessage":"ENOENT: no such file or directory, scandir '/var/task/public/static/locales/fi'","code":"ENOENT","errno":-2,"syscall":"scandir","path":"/var/task/public/static/locales/fi","stack":["Error: ENOENT: no such file or directory, scandir '/var/task/public/static/locales/fi'","    at Object.readdirSync (fs.js:854:3)","    at getAllNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/create-config.js:111:19)","    at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/create-config.js:116:27)","    at new NextI18Next (/var/task/node_modules/next-i18next/dist/commonjs/index.js:53:48)","    at Object.KjaH (/var/task/.next/serverless/pages/_error.js:667:21)","    at __webpack_require__ (/var/task/.next/serverless/pages/_error.js:23:31)","    at Module.cha2 (/var/task/.next/serverless/pages/_error.js:1579:63)","    at __webpack_require__ (/var/task/.next/serverless/pages/_error.js:23:31)","    at Module.iYaR (/var/task/.next/serverless/pages/_error.js:1776:17)","    at __webpack_require__ (/var/task/.next/serverless/pages/_error.js:23:31)"]}
Unknown application error occurred
Error
[GET] /
20:34:51:71
2020-03-14T18:34:52.143Z    undefined   ERROR   Uncaught Exception  {"errorType":"Error","errorMessage":"ENOENT: no such file or directory, scandir '/var/task/public/static/locales/fi'","code":"ENOENT","errno":-2,"syscall":"scandir","path":"/var/task/public/static/locales/fi","stack":["Error: ENOENT: no such file or directory, scandir '/var/task/public/static/locales/fi'","    at Object.readdirSync (fs.js:854:3)","    at getAllNamespaces (/var/task/node_modules/next-i18next/dist/commonjs/config/create-config.js:111:19)","    at createConfig (/var/task/node_modules/next-i18next/dist/commonjs/config/create-config.js:116:27)","    at new NextI18Next (/var/task/node_modules/next-i18next/dist/commonjs/index.js:53:48)","    at Object.KjaH (/var/task/.next/serverless/pages/index.js:1955:21)","    at __webpack_require__ (/var/task/.next/serverless/pages/index.js:23:31)","    at Module.cha2 (/var/task/.next/serverless/pages/index.js:2909:63)","    at __webpack_require__ (/var/task/.next/serverless/pages/index.js:23:31)","    at Module.fvsO (/var/task/.next/serverless/pages/index.js:2992:17)","    at __webpack_require__ (/var/task/.next/serverless/pages/index.js:23:31)"]}
Unknown application error occurred
Error

image

valstu commented 4 years ago

Those fixes are good and it builds fine locally @albacoretuna but it seems like once published to now server the nextjs-i18next tries to fetch the translations from wrong folder 🤔

You can try to reproduce this by publishing the project yourself by just typing now to your terminal if you have now cli installed.

albacoretuna commented 4 years ago

I can take a look later, but I'd suggest we go with the simple pull request instead of fighting nextjs internals too much 😁

jonijuup commented 4 years ago

Thanks @albacoretuna for the fixes! I think you can configure the path manually as well, but don't know if it will fix the issue, if the issue is within how it's build 🤔 I will take a look

valstu commented 4 years ago

I tried to set the path manually but it still doesn't seem to work. There are actually multiple issues related to this in nextj-i18next repo. This is kinda funny because you could expect nextjs translation plugin to work with Now 🤷‍♂

valstu commented 4 years ago

Closing this now, #11 was just published to production since couldn't figure out how to get the path working properly with Now 😞. Thank you for your help with the translations @albacoretuna and @jonijuup. Added you both to contributors in README. 👍

albacoretuna commented 4 years ago

Thank you both!

  1. maalisk. 2020 klo 21.38 kirjoitti notifications@github.com:

Closing this now, > #11 https://github.com/valstu/korona-info/pull/11> was just published to production since couldn't figure out how to get the path working properly with Now 😞. Thank you for your help with the translations > @albacoretuna https://github.com/albacoretuna> and > @jonijuup https://github.com/jonijuup> . Added you both to contributors in README. 👍

— You are receiving this because you were mentioned. Reply to this email directly, > view it on GitHub https://github.com/valstu/korona-info/pull/13#issuecomment-599254713> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/AB2XJYGM5I7Q646VCZGN5ULRHUVDXANCNFSM4LJOSHEA> .