Too many underscores _ _ _ _ _ _ _

Too many underscores _ _ _ _ _ _ _

על ידי Éric Bugnet בתאריך
מספר תגובות: 7
תמונה של Documentation writers תמונה של Plugin developers תמונה של Translators

Hi, all...

I've got this problem : I'm French, and in french language we are using accent (e, é, è, ê...).

I know that, in Internet language, we don't use accent for file name and directory name, and in Moodle all this accents are replace by underscores.

But I'm in a school, and when a teacher post a file named for exemple "l'été est passé", the file name is modified to "l__t__est_pass_".

That's a problem for orthography in school, and for readability.

Can't we replace "é" by "e" and not by "_", the file name will be "l_ete_est_passe" and will be more readable ???

It's not good for orthography, but a little more !

Thank's for your responses.

Eric

ממוצע דרוגים: -
בתגובה ל: Éric Bugnet

Re: Too many underscores _ _ _ _ _ _ _

על ידי Petr Skoda בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Particularly helpful Moodlers תמונה של Peer reviewers תמונה של Plugin developers
There are many different encodings and national characters - PHP has no proper support for them עצוב I guess we will have to wait several years till PHP 6 or 7.

IMO it would be bad to solve only French problem, the global solution is quite complicated, though not impossible, but it would need much time, testing and the code would be rather slow.

If you want to do some custom hack, you can modify the cleaning function clean_filename() from lib/moodlelib.php, simply do the character replacement in the beginning of the function קריצה


skodak
בתגובה ל: Petr Skoda

Re: Too many underscores _ _ _ _ _ _ _

על ידי Éric Bugnet בתאריך
תמונה של Documentation writers תמונה של Plugin developers תמונה של Translators

Hi,

I think I should do that... (thanks for says me what function it is !)

I know that is not only a "Frenchy" problem, but perhaps it's possible to made that for the next Moodle version ? And not only for me and my country ??? I post here for explain my idea...

I prefer not modifying my Moodle and stay with the base Moodle ! (for upgrade...) but I think I'll try !

Ciao

Eric

בתגובה ל: Petr Skoda

Re: Too many underscores _ _ _ _ _ _ _

על ידי Éric Bugnet בתאריך
תמונה של Documentation writers תמונה של Plugin developers תמונה של Translators

Hi again...

It's done, and work :

I just change in function clean_filename() from lib/moodlelib.php

function clean_filename($string) {

/// Cleans a given filename by removing suspicious or troublesome characters

/// Only these are allowed:

/// alphanumeric _ - .

$string = eregi_replace("\.\.+", "", $string);

$string = eregi_replace("é", "e", $string);

$string = eregi_replace("è", "e", $string);

$string = eregi_replace("à", "a", $string);

$string = eregi_replace("ù", "u", $string);

$string = eregi_replace("â", "a", $string);

$string = eregi_replace("ô", "o", $string);

$string = eregi_replace("î", "i", $string);

$string = eregi_replace("ê", "e", $string);

$string = eregi_replace("û", "u", $string);

$string = eregi_replace("ä", "a", $string);

$string = eregi_replace("ö", "o", $string);

$string = eregi_replace("ï", "i", $string);

$string = eregi_replace("ë", "e", $string);

$string = eregi_replace("ü", "u", $string);

$string = eregi_replace("ç", "c", $string);

$string = preg_replace('/[^\.a-zA-Z\d\_-]/','_', $string ); // only allowed chars

$string = eregi_replace("_+", "_", $string);

return $string;

}

Just change this for other languages.

Eric

בתגובה ל: Petr Skoda

Re: Too many underscores _ _ _ _ _ _ _

על ידי Nicolas Martignoni בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Particularly helpful Moodlers תמונה של Plugin developers תמונה של Testers תמונה של Translators
The function "dirify" (adapted from MovableType) will do it rather completely. See here: http://kalsey.com/2004/07/dirify_in_php/

Nicolas
בתגובה ל: Nicolas Martignoni

Re: Too many underscores _ _ _ _ _ _ _

על ידי Martin Dougiamas בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Moodle HQ תמונה של Particularly helpful Moodlers תמונה של Plugin developers תמונה של Testers
Thanks!  Good pointer!  I've included that convert_high_ascii() function as the first step in our function.