[WITH SOME SOLUTION] Avatar Crop error in Spanish/German/Italian/French locale
-
The crop dont fill all image for example: this image crop in this
The error? the translate action produced by the echo with $oitar variable in line 308 of file user-avatar.php with setlocale() in locale with a comma as a decimal symbol. (French, German, Spanish, Italian)
In Spanish the decimal symbol is a ‘comma’ (,), not a dot (.) but in computer languages (included php, of course) in ALL idioms has dot (.) . The setlocale(LC_ALL, ‘es_ES’); translate the number in $oitar to spanish decimal symbol, for example:
$oitar=1.28543; echo $oitar; /* this return 1.28543 (in php is recognized as float when operate it)*/ setlocale(LC_ALL, 'es_ES'); echo $oitar; /* this return 1,28543 (in php is recognized as string when operate it, then php try to transform this to float, php can't translate the comma, then return the number <em>before</em> comma = one (1). */
When the plugin use wp_crop_image() for crop the image, the user selected width has transform to the final width only if $oitar > 1 (line 394 of same file), this is math relation, 1,28543 is translate as 1, then 1>1 is false.
The Solution?
The ideal: Zend will MUST solve this, i like use echo for print in screen, not for format! If i like format i may use number_format()!
The reality: In the start of the function user_avatar_add_photo_step2 in line 246 of the same file i can put:
setlocale(LC_NUMERIC, 'C');
an this solve it.
Information about this “curiosity” of PHP with setlocale():
https://www.php.net/manual/en/function.setlocale.php#25041 (THIS IS FROM 2002! and more others recent)
https://www.code-styling.de/english/php-function-setlocale-and-numbers-can-be-damaged (this is from 2009!)
https://grokbase.com/t/php/php-bugs/098ea69z35/49254-new-setlocale-affects-math-functions (this is from 2009!)
https://stackoverflow.com/questions/2906326/setlocale-to-fr-fr-in-php-and-number-formatting (2010!)
- The topic ‘[WITH SOME SOLUTION] Avatar Crop error in Spanish/German/Italian/French locale’ is closed to new replies.