Page layout thumbnails are missing in languages that have changed the layout lang strings

Bug #1461040 reported by Peter Groißböck
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Robert Lyon
15.04
Fix Released
High
Robert Lyon
15.10
Fix Released
Undecided
Unassigned

Bug Description

In 15.04 there are noch pictures of the layouts visible anymore. The layouts are still there, but you can't see what layout it is because of the missing picture. Windows. Firefox 38.0.1.

Revision history for this message
Robert Lyon (robertl-9) wrote :

Hi Peter,

In Mahara 15.04.1 the layout 'images' are not image files anymore but instead are Scalable Vector Graphics (SVG) rendered directly by the browser.

I've checked firefox 38.0.1 on windows and I can see the layout 'images'

If you do a view of the source code for the layout page do you see code similar to this:
 <svg aria-labelledby="titlelid556e7781ec001 desclid556e7781ec001" height="48" width="76" role="img" xmlns="http://www.w3.org/2000/svg">
  <title id="titlelid556e7781ec001">Layout preview image</title>
  <desc id="desclid556e7781ec001">67-33</desc>
  <rect class="layout1" height="48" width="48.91" y="0" x="0"/><rect class="layout1" height="48" width="24.09" y="0" x="51.91"/>
 </svg>

The colours for these come from the theme/raw/static/style/style.css file and the .layoutthumb rect.layout0 and .layoutthumb rect.layout1 styles in particular.

Are you able to check if those styles are being applied to the <rect> tag?

Cheers

Robert

Changed in mahara:
status: New → Incomplete
Revision history for this message
Robert Lyon (robertl-9) wrote :

Ah - it seems to be related to the language you view the page in.
In English it works fine but in German (for instance) the page looks broken.

Ok, now that I see what is going wrong I should be able to fix it.

Changed in mahara:
status: Incomplete → In Progress
importance: Undecided → Critical
assignee: nobody → Robert Lyon (robertl-9)
milestone: none → 15.10.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

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

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

Reviewed: https://reviews.mahara.org/4818
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/b913791c5f68e8f1d5d5719797e7c01a01b0970c
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit b913791c5f68e8f1d5d5719797e7c01a01b0970c
Author: Robert Lyon <email address hidden>
Date: Thu Jun 4 10:30:18 2015 +1200

Bug 1461040: Stopping layout thumbs being created from langstring info

There is no need to go to tha lang string info as the items already
have the layout info we need.

Currently breaks where lang packs have the strings defined to
something else

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

Aaron Wells (u-aaronw)
Changed in mahara:
importance: Critical → High
status: In Progress → Fix Committed
Revision history for this message
Aaron Wells (u-aaronw) wrote : Re: no layouts visible

The easiest way to replicate this:

1. Create a file htdocs/local/lang/en.utf8/view.php

2. In that file, put these contents:

<?php
$string['33,33,33'] = '33,33,33';

3. Log in to Mahara and go to a page's "Layout" tab.

Expected result: You should see the thumbnails of all the layouts

Actual result: Some layouts will be missing or incomplete (the ones where they have a 33,33,33 row in them)

And conversely, a workaround to fix this, if you're using an affected langpack, is to put in place a local/lang file that replaces all the layout strings with the (hyphenated) layout strings from the default htdocs/lang/en.utf8/view.php file.

This bug only affects Mahara 15.04 and 15.10dev, because it's caused by the code that generates the layout thumbnails as SVGs.

Cheers,
Aaron

description: updated
summary: - no layouts visible
+ Page layout thumbnails are missing in languages that have changed the
+ layout lang strings
Revision history for this message
Aaron Wells (u-aaronw) wrote :

To clarify (because I think it wasn't spelled out in Robert's or my earlier comments), the cause of the problem here is that the code that generates those layout thumbnails is parsing some lang strings that describe the percentage of width of columns.

In the core en-utf8 langpack, these strings look like this:

$string['100'] = '100';
$string['50,50'] = '50-50';
$string['33,33,33'] = '33-33-33';
$string['25,25,25,25'] = '25-25-25-25';
$string['20,20,20,20,20'] = '20-20-20-20-20';
$string['67,33'] = '67-33';
$string['33,67'] = '33-67';
$string['25,25,50'] = '25-25-50';
$string['50,25,25'] = '50-25-25';
$string['25,50,25'] = '25-50-25';
$string['15,70,15'] = '15-70-15';
$string['20,30,30,20'] = '20-30-30-20';

In the German langpack, they have been changed to this:

$string['100'] = 'Gleiche Spaltenbreite';
$string['15,70,15'] = 'Viel größere mittlere Spalte';
$string['20,20,20,20,20'] = 'Gleiche Spaltenbreite';
$string['20,30,30,20'] = 'Größere Mittelspalten';
$string['25,25,25,25'] = 'Gleiche Spaltenbreite';
$string['25,25,50'] = '25-25-50';
$string['25,50,25'] = 'Größere mittlere Spalte';
$string['33,33,33'] = 'Gleiche Spaltenbreite';
$string['33,67'] = 'Größere rechte Spalte';
$string['50,25,25'] = '50-25-25';
$string['50,50'] = 'Gleiche Spaltenbreite';
$string['67,33'] = 'Größere linke Spalte';

This is a bug in Mahara. We should not be parsing the values of language strings. Robert's fix is to change the code so that instead it parses the string *identifiers* (e.g., "100", "15,70,15", etc).

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/4820

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

Reviewed: https://reviews.mahara.org/4820
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/50710e07cd1d352f0bdfcca8203c93b824558d09
Submitter: Aaron Wells (<email address hidden>)
Branch: 15.04_STABLE

commit 50710e07cd1d352f0bdfcca8203c93b824558d09
Author: Robert Lyon <email address hidden>
Date: Thu Jun 4 10:30:18 2015 +1200

Bug 1461040: Stopping layout thumbs being created from langstring info

There is no need to go to tha lang string info as the items already
have the layout info we need.

Currently breaks where lang packs have the strings defined to
something else

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

Revision history for this message
Peter Groißböck (peter-groissboeck) wrote :

Thanks for your help!

It works better now, but it's not really working.
You can see some, but definitely not all of them.
Shall we wait for the release of Mahara 15.04.2?

Thanks!

Yours,

Peter

Revision history for this message
Kait Krull (kaitkrull) wrote :

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
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

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

Revision history for this message
Robert Lyon (robertl-9) wrote :

I've added a fix for the problem with php locales that use comma instead of period for decimal notation as mentioned by Kait

Changed in mahara:
status: Fix Committed → In Progress
Revision history for this message
Aaron Wells (u-aaronw) wrote :

I've spun off Bug 1468144 to cover the problem of breakage in locales that use commas for decimals, because, while it has some of the same symptoms, it's a separate bug.

I'll mark this bug (which deals only with the layout percentage lang strings issue) as "Fix released".

Changed in mahara:
status: In Progress → 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.