Website globalization can be defined as the process of designing a website so that it can potentially be adapted to various languages and regions. While reading that definition, we may think that it’s a simple topic, but from my personal experience, it is not something that is easy to achieve.
Website globalization is not just translating content into different languages. It also includes adjusting other aspects like number formatting and how dates should be displayed. When it comes to numbers, for example, some countries use a comma and others use a dot as a decimal separator. For dates, some regions have different ways to display the month, day and year. Globalization gives users the ability to input numbers and dates in the format they are accustomed to.
In this blog, I will cover some of the resources that are available to globalize your Node.js web applications. Why Node.js? Mainly because it’s an environment that is broadly used. It helps developers easily build apps from scratch and has a helpful community with a lot of documentation and libraries available.
It is not tied to any framework and works both in the browser and in Node.js.
It uses Unicode CLR, which is the largest and most extensive standard repository of locale data.
It handles date and number formatting very well.
It is supported in desktop and mobile browsers and Node.js.
It is very user-friendly.
Vue-i18n is an internationalization plugin for Vue.js. It has support for text formatting, handles text with html tags pretty well and includes support for custom formatting. It also supports number, date and time localization, language fallback and component-based localization.
There is a standard called ECMA-402, which defines an internationalization API for ECMAScript objects and has many interesting features. Although ECMA-402 support is improving among modern browsers and even Node.js, the functionality and locale coverage level varies between different environments. In the following picture you can see the results of running unit tests for ECMA support in different browsers. For a better reference, please see this link.
Node.js includes internationalization APIs from release 0.12.0. By default, only the English (U.S.) locale is included. To enable the internationalization APIs to work in other languages and locales, you need to include the optional locale data that comes from the International Components for Unicode Project. For a better reference about how to include that optional locale data, please see this link.
The main strengths include:
There are many resources available to globalize your Node.js app, including libraries that better integrate with some existing frameworks. It’s up to you when selecting the technology that best fits your use case. Always consider using technologies that allow you to structure the content in a way that can be easily exported for translation and imported back. Also, it’s good to consider technologies that allow you to add support for new languages in a simple way.