Skip to content →

Tag: i18n

Libraries for Translating JavaScript Apps

In the previous articles we have seen how to perform localization in back-end: specifically, we’ve covered Rails and Phoenix frameworks. Today, however, we are going to talk about libraries for translating JavaScript apps and briefly see them in action. It appears that there are quite a lot of available solutions, so you may ask: “Which one should I use?”. The most obvious (and perhaps the most sane) answer would be: “It depends”. Ideally, you should check each library and then decide which one you prefer.

Therefore, in this article I will give you a general introduction to the following solutions:

  • Globalize
  • I18next
  • jQuery.I18n
  • Polyglot.js

Note that we will be talking about localizing vanilla JS apps, not about some specific client-side framework. Also, we won’t dive deep into each library because the article would become much, much longer. I’ll only give you a gentle introduction to each tool and then we’ll try to compare them and come to some general conclusion.

Shall we start?

Store Translations Inside Database With Globalize

In one of our previous articles we were talking about the process of internationalizing Rails applications. That article explained all I18n basics, but it was revolving around placing all translations inside YAML files. There is nothing wrong about this approach, but unfortunately it does not always work. Suppose, your website has lots of user-generated content which should be adapted for different languages. Therefore, I propose to store your translations inside database. Why YAML files won’t work in this case?