#Read local i18n json files

5 messages · Page 1 of 1 (latest)

sick musk
#

I have a worker running a Discord bot and want to start building up i18n for it. I have structure set up, but need a way to load the json lang files. If anything I may just fall back to a basic include and change up the files slightly.

TIL this isn't Node.js, but "workerd". So fs.readFileSync isn't available.

I tried reading over this blog post but it along with my messed up sleep is making my brain hurt. It's not making any sense. not sure if it's even relatable or not.
https://blog.cloudflare.com/more-npm-packages-on-cloudflare-workers-combining-polyfills-and-native-code/

I have files at:

  • ./src/api/i18n/en-US.json
  • ./src/api/i18n/es-ES.json
  • ./src/api/i18n/it.json
  • etc.

Main entry is at ./src/api/server.js so it just refers to ./i18n/{lang}.json

The Cloudflare Blog

Workers now supports more NPM packages and Node.js APIs using an overhauled hybrid compatibility layer.

#

Read local i18n json files

#

Don't know if I'm looking at this correctly, but it seems like it's just a 'here's how you can make a function match the module so the "function doesn't exist" error goes away' but does nothing for actually making it do what it should lol

turbid narwhal
sick musk
#

Wasn't planning on it that way and I didn't want to deal with mapping it all out and whatnot tbh lol