Text encoding for spanish & italian

Text encoding for spanish & italian

by Christos Vasilikiotis -
Number of replies: 7
Hi,

I am setting up a new moodle site where we will have courses in spanish and italian in addition to english.
When I try to see the pages in spanish or italian, all the accented letters do not show up properly. I tried setting my browser (Safari-MacOSX 10.3.4) to different encodings, but nothing works. I had the same problem using Windows XP, so it is not a Mac problem.

I read in the forums that changing the charset to UTF-8 is the solution.
In the Italian forum, they suggested:

should comment the following line in
the httpd.conf file setting UTF-8 as a default charset:

"AddDefaultCharset UTF-8"

you should put # before at the beginning of the line and run the program
again.

I am using a hosting company so I don't have access to the httpd.conf file. I also do not know how to do this using the .htaccess file (if anyone has a script they wrote for this I would greatly appreciate it).

In another discussion, it was mentioned that changing the charset in moodle.php to UTF-8 would solve the problem. I did this, but oddly it only works when I view the page with my browser set to IS0 Western Latin-1, but not when I set it to UTF-8.

So at this point I am totally lost. Do other users in spanish and italian (and other languages for that matter) have similar problems? How do you solve them? I also tried viewing the page in Greek and found the exact same problems.

Any help would be greatly appreciated.

Christos
Average of ratings: -
In reply to Christos Vasilikiotis

Re: Text encoding for languages

by Christos Vasilikiotis -
Follow up:

I set up the same version of moodle (1.3.3) on another server and now all languages appear correctly. Even greek characters work in the Greek Language set.

What do I need to change in the first server where non-english languages do not display properly? Is there a setting that I can change in moodle? Or do the hosting company has to modify the PHP installation on their server?

Thanks,
Christos
In reply to Christos Vasilikiotis

Re: Text encoding for languages

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
A workaround for this was made in the source recently.

Look in print_header() in lib/weblib.php.

After this line:

$meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";

Add this:

if (!$usexml) {
    @header('Content-type: text/html; charset='.$encoding);
}


In reply to Martin Dougiamas

Re: Text encoding for languages

by Christos Vasilikiotis -
Thanks Martin,

I am a total newbie when it comes to PHP code so please bear with me wink

In the print_header there is already the following line:

if ($usexml) { // Added by Gustav Delius / Mad Alex for MathML output
$currentlanguage = current_language();

@header("Content-type: text/xml");
echo "\n";
if (!empty($CFG->xml_stylesheets)) {
$stylesheets = explode(";", $CFG->xml_stylesheets);
foreach ($stylesheets as $stylesheet) {
echo "wwwroot/$stylesheet\" ?>\n";
}
}
Will it conflict with the one you mentioned or the two can coexist?

Cheers,
Christos
In reply to Christos Vasilikiotis

Re: Text encoding for spanish & italian

by Ernesto H -

instead of  "AddDefaultCharset UTF-8" line,  use the following:

"AddDefaultCharset ISO-8859-1"

Greetings

Ernesto

In reply to Ernesto H

Re: Text encoding for spanish & italian

by Christos Vasilikiotis -
Hi Ernesto,

Thanks for the suggestion.

I realized that since I am using a hosting company for my web site I cannot alter the httpd.conf file (and they do not want to alter it either since it would affect everyone on that server).

I was told that I can put that line in an .htaccess file inside moodle. Will that work the same? I saw that there is already a file htaccess inside moodle/lib. Should I add the line to that file or move that file first to my main moodle directory (and rename it .htaccess) and then add the line? It mentions in the htaccess file that moving it could cause problems to the web site.

Cheers,
Christos
In reply to Christos Vasilikiotis

Re: Text encoding for spanish & italian

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
It's better not to have that line at all (in httpd.conf or .htaccess). The previously mentioned script change overrides all of it anyway.