collectiveaccess/providence — pull request #27 by gautiermichelin (2013-03-14 01:26:40+00:00)
Title: improving length measures and l10n

Hi Seth,

this pull request solves those mostly l10n problems :
- en_US : "12⅔ ft" was not recognized
- fr_FR : "12,4 cm" was saved to "12,0 cm" but "12.4 cm" was saved as "12,4 cm"
- fr_FR : fractions were not usable

After patch, all those measures are handled :
- en_US : "12 cm", "12.3 cm", "12 1/2 cm", "12⅔ cm"
- fr_FR : "12 cm", "12,3 cm", "12 1/2 cm", "12⅔ cm"

Most of the work is done through 4 helpers (2 pre-existent caConvertFractionalNumberToDecimal and caConvertLocaleSpecificFloat ; 2 new : caConvertFloatToLocale and caGetDecimalSeparator) : the 2 pre-existent helpers have only a new optional parameter.

Bye,

Gautier

----------------------------

Commits messages gathered :

##### Fixing position of caConvertFractionalNumberToDecimal() to allow Unicode fraction glyphs like 12⅔ ft
In order to allow unicode glyphs, the call of the replacement function must be before the
preg_match("!^([\d\.\,/ ]+)[ ]*([^\d ]+)!", $vs_expression, $va_matches)
otherwise unicode fraction are filtered.

##### Managing l10d numbers : 2 helpers modified, 2 new helpers
- caConvertFractionalNumberToDecimal : now takes $locale as a 2nd optional parameter, float results are now returned back respecting the locale (fr_FR : "1 1/2 cm" => "1,5 cm")
- caConvertLocaleSpecificFloat : modified to use NumberFormatter class, included in PHP >= 5.3, easier to read and doesn't rely on the locale of the server as in localeconv() call
- caConvertFloatToLocale : reciprocal function, use NumberFormatter class to convert a standard number to a l10d number
- caGetDecimalSeparator : use NumberFormatter class to extract the decimal separator

##### LengthAttributeValue::parseValue() : calling locale numbers helpers to improve l10d strings treatment

##### Small translation improvement
"%1 n'est pas une mesure valide" => "%1 ne contient pas une mesure valide"