Internationalization and localization tools


Locale-Sensitive JavaScript Constructor

String(object);

Internationalization (I18n) Method Overview

This constructor converts object to a string and is dependent on the object type. For example, String(boolean) will create a true or false string; String(number) will create a locale-independent (i.e. fixed format) number string; and String(date) will create a U.S. English formatted date string in the system's local time zone.

Click here (w3schools) and here (MDN) for additional constructor details.

I18n Issues

String does not take into account the locale of the application when converting object to a string; instead the created string will always be a fixed format - displaying English in the case of boolean values and date formatting, and using U.S. English numeric notation in the case of number values. You will need to look at each String call to ensure that boolean, number and date calls are performing as expected once your application supports multiple locales and a time zone other than your system's time zone.

Suggested Replacement

To format dates, times and numbers based on locale and a time zone other than the system time zone, call one of the following methods:

toLocaleDateString
toLocaleString
toLocaleTimeString

In the case of String(boolean) you should instead retrieve a corresponding true/false string from a locale-sensitive resource file.


Globalyzer will detect this method and report it as an I18n issue. If you have determined that the call is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.



Locale-Sensitive JavaScript Methods

 

Lingoport internationalization and localization services and software