Internationalization in JavaScript with NodeJS

preview_player
Показать описание
Tutorial showing how to use the Intl JS API in NodeJS (i18n). We'll install a module to unlock the Intl API languages for Node and test out RelativeTimeFormat to translate and localise relative times in JavaScript. I'll tell you how to get started with the built-in internationalization library in JS for Node 12 and higher. We'll change the locale to see how the translation works and test different BCP 47 language tags.

Internationalization is a difficult undertaking but using the Intl API is an easy way to get started, it's great to see this new API in the JS language and available for use. Soon, you'll be able to have confidence using it in the browser as modern browsers support the major Intl features. Have a look at the browser compatibility charts to see which browsers and versions of node are supported.

Use Intl.RelativeTimeFormat for language-sensitive relative time formatting.
#javascript #nodejs #webdevelopment

MDN Documentation:

Full ICU NPM package:

---
🐦 Follow me on twitter:

📝 Read my blog:

👨‍💻Join me on the DEV community:

📰 Read my articles on Medium:

🐙 See my public code on GitHub:

---
If you have any suggestions for new tutorials, leave a comment or tweet me.
---

Subscribe to my channel for more tutorials helping you to craft cool user interfaces on the web with all the tools which are available from JavaScript, CSS and HTML to specific web APIs. I cover Framer Motion and React libraries in-depth so you can learn how to achieve animations on the web and build more intuitive web apps.
Рекомендации по теме
Комментарии
Автор

📣 I'm branching out and making some different (and hopefully useful) tutorials in addition to the Framer Motion tutorials.
As always, leave a comment if you'd like to see a specific topic 🙏

DarthKnoppix
Автор

could you add more on localization, i18 ?

ironhide
Автор

Hello @seth How has this updated since node 14 i don't think we need to install any external dependency.

deresegetachew
Автор

In my project, it is not ideal to run node with the `--icu-data-dir` flag every time we execute a script, but when I try to add the NODE_ICU_DATA to our .env file, it does not work even though I can console log out that variable and it displays correctly while scripts are running. Do you have any advice for setting this up as an environment variable for node 12? I know that node 13+ comes with full icu by default.

jakeave