Internationalization and localization tools


Locale-Sensitive JavaScript Method

parseFloat(string);

Internationalization (I18n) Method Overview

The parseFloat method parses the string argument, returning a floating point number. It will parse until it finds a character that is other than a leading sign, number, decimal point or exponent (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

parseFloat is a locale-independent method, meaning that the number must be formatted using a period for the decimal point, +/- for the positive and negative sign, and include no thousands separator, regardless the locale. 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

To ensure that the locale is used when parsing the string argument, call parseLocale, if you are using Microsoft's .NET Framework JavaScript Extensions. 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