Internationalization and localization tools


Locale-Sensitive JavaScript Method

parseInt(string);
parseInt(string, radix);

Internationalization (I18n) Method Overview

The parseInt method parses the string argument, returning an integer number. The radix argument indicates the number system to use (e.g. 10, 16, 8); if it is not included, then the determination of the radix based on the string alone may be incorrect. parseInt will parse until it finds a character that is other than a leading sign or number supported by the radix (leading and trailing spaces are skipped); returning NaN if there are no number characters to convert.

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

I18n Issues

parseInt is a locale-independent method, meaning that the number must be formatted using +/- for the positive and negative sign, a period for the decimal point, and include no thousands separator. If the string is to be formatted based on locale and then parsed to create a number, this method should not be used.

Suggested Replacement

If you are using Microsoft's .NET Framework JavaScript Extensions and need to convert a string that is based on locale to an integer, call parseLocale. Otherwise, you will need to use a 3rd party JavaScript library that will parse number strings based on locale.


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