Moodle

UTF-8 non breaking spaces in language packs cause display problems

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.6
  • Fix Version/s: 1.8.1, 1.9
  • Component/s: General, Language
  • Labels:
    None
  • Affected Branches:
    MOODLE_16_STABLE
  • Fixed Branches:
    MOODLE_18_STABLE, MOODLE_19_STABLE

Description

If the language pack contains UTF-8 encoded non breaking spaces, some strings display wrong.

To reproduce, follow these steps:
1) Switch to the french language.
2) Log in and see "Connecté sous le nom « Your Name Here »" in the top right of the window (correct behaviour).
3) Log out
4) In the file moodle.php of the french language pack, replace the   in the string $string['loggedinas'] with a UTF8 encoded non breaking space.
5) Log in and see the "Connecté sous le nom «" (nothing more) in the top right of the window (bug).

The correction of this bug could be very handful, as it will allow a better lisibility of the lang pack and the consistent use of non-breaking spaces in all strings (i.e also those that are sent by standard mail, which doesn't support HTML entities).

Issue Links

Activity

Hide
Michael Blake added a comment -

Only need to specify the first version in which the problem was found.

Show
Michael Blake added a comment - Only need to specify the first version in which the problem was found.
Hide
Nicolas Martignoni added a comment -

Display problems in Javascript warning popups, as they don't interpret   entities.

Show
Nicolas Martignoni added a comment - Display problems in Javascript warning popups, as they don't interpret   entities.
Hide
Nicolas Martignoni added a comment -

To workaround this bug, I removed all the UTF8 non breaking spaces from the french lang pack, so this doesn't seem to be reproducible.

Show
Nicolas Martignoni added a comment - To workaround this bug, I removed all the UTF8 non breaking spaces from the french lang pack, so this doesn't seem to be reproducible.
Hide
David Mudrak added a comment -

Would automatic removing of all UTF8 non breaking spaces during the file save acceptable?

Show
David Mudrak added a comment - Would automatic removing of all UTF8 non breaking spaces during the file save acceptable?
Hide
Nicolas Martignoni added a comment -

No, because:

1) The non-breaking spaces ARE important (at least in french), so we shouldn't remove them, but instead replace them with   HTML entities (I meant this in my preceding comment, sorry for the bad explanation) during the file save. Note that as of 1.8dev, the file save strips these   entities, which is bad (and I should perhaps open another bug issue for this one).

2) Some translator (me ), for efficiency, doesn't use the Moodle interface to translate the strings. The conversion described in the above point would be for them of no use.

If it was feasible, I would suggest to workaround the lacking UTF-8 support of the sprintf() PHP function used in get_string_from_file() (in lib/moodlelib.php). This way, we could write the strings in UTF-8 without any doubts.

See for a suggested solution here : http://www.php.net/manual/en/function.sprintf.php#55837

Show
Nicolas Martignoni added a comment - No, because: 1) The non-breaking spaces ARE important (at least in french), so we shouldn't remove them, but instead replace them with   HTML entities (I meant this in my preceding comment, sorry for the bad explanation) during the file save. Note that as of 1.8dev, the file save strips these   entities, which is bad (and I should perhaps open another bug issue for this one). 2) Some translator (me ), for efficiency, doesn't use the Moodle interface to translate the strings. The conversion described in the above point would be for them of no use. If it was feasible, I would suggest to workaround the lacking UTF-8 support of the sprintf() PHP function used in get_string_from_file() (in lib/moodlelib.php). This way, we could write the strings in UTF-8 without any doubts. See for a suggested solution here : http://www.php.net/manual/en/function.sprintf.php#55837
Hide
David Mudrak added a comment -

I see know - I am sorry for misunderstanding. After today's playing with lang.php, I have created two subtask for this issue. The first patch will be quite easy - at my notebook, Moodle is already keeping   and   as a part of translated string. However, I would like to save this nb-space in pure Unicode in .php files and not as HTML entity.

But, I am still having problem with direct typing Alt+0160 or copying a nbsp from other sources (text files, emails etc.). Maybe the problem is only with my browser. I need you assistance - can you please check MDL-8500, download the published script, try it at your server/browser and report the result, please?

Thank you.

Show
David Mudrak added a comment - I see know - I am sorry for misunderstanding. After today's playing with lang.php, I have created two subtask for this issue. The first patch will be quite easy - at my notebook, Moodle is already keeping   and   as a part of translated string. However, I would like to save this nb-space in pure Unicode in .php files and not as HTML entity. But, I am still having problem with direct typing Alt+0160 or copying a nbsp from other sources (text files, emails etc.). Maybe the problem is only with my browser. I need you assistance - can you please check MDL-8500, download the published script, try it at your server/browser and report the result, please? Thank you.
Hide
David Mudrak added a comment -

Partially fixed: lang.php preserves   entities.

Show
David Mudrak added a comment - Partially fixed: lang.php preserves   entities.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: