Page layout thumbnails are broken if you use a locale that does commas for decimals

Bug #1468144 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Robert Lyon
15.04
Fix Released
Medium
Robert Lyon
15.10
Fix Released
Medium
Robert Lyon

Bug Description

This bug is a follow-up to Bug 1461040. The code in Mahara that generates SVG files for page layouts, breaks if you are using a locale that does commas for decimals, instead of periods. e.g. one half is "0,5" rather than "0.5".

Here's a quote from the other bug:

I also encountered this after beginning with translation of Mahara 15.04 into Estonian. As the locale setting have also been changed the values returned by PHP (please correct me if I am wrong) will be comma separated and not separated with decimal point (due to Estonian representation of float numbers). So Peter probably sees only the SVG images which are not returned with float values. Small output of false return values which are not rendered by browser: <rect x="52,2" y="18"..></rect>. (should be x="52.2")

This also affects gallery where the images should be centered but due to false float values are not.

The fix provided at the moment helps, but does not solve the float number representation. I have chosen to replace "," in returned values with "." in layoutpreviewimage.php and it has "solved" the problem. I am open for better solutions.

I hope this helps a bit.

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Patch for "master" branch: https://reviews.mahara.org/4838

description: updated
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Here's the part of the SVG specifications that says decimals must use a "." rather than a ",": http://www.w3.org/TR/SVG/paths.html#PathDataGeneralInformation

" The only allowable decimal point is a Unicode U+0046 FULL STOP (".") character (also referred to in Unicode as PERIOD, dot and decimal point) and no other delimiter characters are allowed [UNICODE]. (For example, the following is an invalid numeric value in a path data stream: "13,000.56". Instead, say: "13000.56".) "

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/4910

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Replication instructions:

To test this, you'll need to change your Locale. For Ubuntu, you can do that using instructions from here: http://askubuntu.com/questions/76013/how-do-i-add-locale-to-ubuntu-server

1. Install the Dutch language locale on your computer:

 sudo locale-gen nl_NL.UTF-8
 sudo update-locale

2. You'll also need to force Mahara to use that new locale. Normally, Mahara uses a method called "set_locale_for_language()" to try to set the locale to match the current language pack. So you can either install the Dutch language pack, or hack set_locale_for_language(). It's in the htdocs/lib/mahara.php file. Add this to the top of the set_locale_for_language() function:

 setlocale(LC_ALL, 'nl_NL.UTF-8');
 return;

3. Having done this, log in to Mahara and go to Portfolio -> Pages.
4. Create or edit a page, and go to the "Layout" tab

Expected result: You should see thumbnails for all the layouts
Actual result: Thumbnails for several layouts will be missing

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Patch for "master" branch: https://reviews.mahara.org/4911

Revision history for this message
Aaron Wells (u-aaronw) wrote :

To replicate the gallery block issues:

0. Set your locale to Dutch as described in my previous comment.
1. Log in to Mahara
2. Go to Content -> Files. Create a folder. Put some images in there. Make sure at least one of them is wider than it is tall (i.e., landscape)
3. Go to Portfolio -> Pages. Create a page. Put an "Image gallery" block on the page. Select the folder that you uploaded your images into.
4. Set the "style" for the gallery block to "Thumbnails (square)"
5. View the page

Expected result: The landscape-ratio pictures should show up as thumbnails inside a square box. They should be vertically centered in the middle of the square box.

Actual result: The landscape-ratio thumbnails are floating up against the top of their surrounding box.

In my testing, this bug only affected landscape images, not portrait images.

Changed in mahara:
status: New → In Progress
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4910
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/ee8969c6956d43872746e2af660c82ffc825cbf2
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit ee8969c6956d43872746e2af660c82ffc825cbf2
Author: Robert Lyon <email address hidden>
Date: Wed Jul 1 15:02:01 2015 +1200

Bug 1468144 - fixing issues with gallery and locale

Change-Id: I2be7082789f872ca02e2abcf838fbd959c5d8677
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/4838
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/8c88e64b471db10b1c896ae875896560d59a11f0
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 8c88e64b471db10b1c896ae875896560d59a11f0
Author: Robert Lyon <email address hidden>
Date: Mon Jun 15 17:03:34 2015 +1200

Fixing the layout images being broken by locale setting

Bug 1468144

If your php site locale is one that uses comma as decimal seperator,
eg in Dutch 12,5 is the same as 12.5 in English then the layout thumbs
break.

Need to change , back to . for it to work.

The best way to do this would be to set the locale to english for the
layout creation and then set it back again but we can't be sure which
english is available so I've just done a str_replace of , to .

Change-Id: I807eda47e76d3654137681bded26164e535eb9eb
Signed-off-by: Robert Lyon <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/4912

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4912
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/978cbe7a62acccc2f04b960b046ce68a1850af1a
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit 978cbe7a62acccc2f04b960b046ce68a1850af1a
Author: Robert Lyon <email address hidden>
Date: Mon Jun 15 17:03:34 2015 +1200

Fixing the layout images being broken by locale setting

Bug 1468144

If your php site locale is one that uses comma as decimal seperator,
eg in Dutch 12,5 is the same as 12.5 in English then the layout thumbs
break.

Need to change , back to . for it to work.

The best way to do this would be to set the locale to english for the
layout creation and then set it back again but we can't be sure which
english is available so I've just done a str_replace of , to .

Change-Id: I807eda47e76d3654137681bded26164e535eb9eb
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 8c88e64b471db10b1c896ae875896560d59a11f0)

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/4911
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/96e86d13b792053863851ee2c87d8c1db032f26f
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 96e86d13b792053863851ee2c87d8c1db032f26f
Author: Robert Lyon <email address hidden>
Date: Wed Jul 1 15:02:01 2015 +1200

Bug 1468144 - fixing issues with gallery and locale

Change-Id: I2be7082789f872ca02e2abcf838fbd959c5d8677
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.