Internationalization and localization tools


Locale-Sensitive JavaScript Method

string.valueOf();
number.valueOf();
date.valueOf();
boolean.valueOf();
array.valueOf();

Internationalization (I18n) Method Overview

This method returns the primitive value of an object, and is dependent on the object type.

For example:

string.valueOf returns the string
number.valueOf returns a locale-independent (i.e. fixed format) number
date.valueOf returns the number of milliseconds from midnight January 1, 1970 UTC
boolean.valueOf returns true or false
array.valueOf returns the array

For more details on general Object valueOf, cick here (MDN).

Otherwise, click on a specific object type valueOf link below (w3schools):

string.valueOf
number.valueOf
date.valueOf
boolean.valueOf
array.valueOf

I18n Issues

valueOf should not be used for display purposes as it does not take into account the application's locale.

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 boolean.valueOf you should instead retrieve a corresponding true/false string from a locale-sensitive resource file.

If String and Array objects have text that will be displayed in the UI, the text may first need to be retrieved from locale-sensitive resource files.


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