DEV Community

Marcin Wosinek
Marcin Wosinek

Posted on • Originally published at how-to.dev

5 JavaScript internationalization libraries that look interesting

I've been in angular(.js) bubble for a pretty long time. During this, I was happily using some framework-specific tools for managing translations - mostly angular-translate. Unfortunately, those tools are limited to the framework and don't help in another context.

Key considerations

What I liked about the setup I had so far:

  • short key names - I prefer t('abstract_keys') over t('The source language message'), as it takes less space in the code
  • JSON translation files. With abstract keys, they could even be scoped by adding dots to the translation keys
  • tooling for automatically extracting keys from source code & adding them to all language files

On top of that, now I want framework independent solution. Internationalization (i18n) is a problem complex enough to have some serious thinking invested in it, and it's completely unrelated to problems solved by JS frameworks.

First impressions

I did a quick search to see what's out there. Some libraries seemed very suspicious just by the look by the websites; others failed to point towards covering points I listed above.

i18next

i18next looks the most impressive - it looks more like a translation ecosystem than just an i18n library. I would need to experiment with it a bit to really tell how well it delivers its promises, but definitively it is at least trying to address all my considerations.

polyglot.js

A library from Airbnb - they do well with i18n, so it's worth taking a look.

LinguiJS

At least the documentation looks like from the current decade. It can be worth checking.

fluent

A solution that tries to cover all possible edge cases of applying genders, complex plurals for languages with less straightforward grammar - for example, Polish.

Rosetta

A general purpose internationalization library in 292 bytes

I want to see it in action! And how far you can get with such a minimalistic solution.

And you?

What are your thoughts about i18n in JS? Any library you would recommend me to add or remove from my list?

Discussion (0)