If you are planning to work with multiple languages, you need to add internalization support to your web applications. We will see how the i18n and l10n access can be embedded in our code to help design and develop web applications that enable easy localization for different cultures, regions, and languages. The topics that will be covered in this chapter are as follows:
Intl
libraryThe development of globalized software is not a simple task. In general, the standard development process to create globalized software includes the following steps:
We will start designing and developing globalized software with the Intl
library from the intl
package available on the pub manager and follow some rules that will help us to easily translate and customize our application.
All executable code must be separated from the programming code that implements the User Interface (UI). Also, code that describes the UI elements and the layout of the UI elements must be kept separated from the code that implements and manages them.
Various cultures have different ways to represent numbers and dates. You must avoid converting numbers and dates into strings directly.
Often, messages that contain individual pieces of text are used together to create complete sentences. In the process of localization, these pieces of text might go together in a different order. Using the message
method of the Intl
class allows you to display messages as simple expressions.
Measuring units such as meters and miles and currencies such as USD and Euro are ubiquitous and depend on the locale. The NumberFormat
class contains special constructors for the quick creation of frequently used patterns that can be very handy to measure units and currencies.
The size of the text on the screen is one of the biggest problems that affect programmers who develop globalized software. The main reason for this is that any assumption about the width of the text, the direction of its flow, and its position on the screen, if incorrect, can hamper well-structured layouts in a flash. Using the BidiFormatter
class helps manage messages that contain text in both the text directionalities.
3.12.166.131