Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Alejo Becerra Diaz -
Number of replies: 9
Well, that's all. I want to know what's the advantage, since we all know there are certain disadvantages (I'm coping with one: galleacian/gl language in Moodle but no gallaecian locale for Windows...)
Thanks in advance. I Hope this in not a too simple question for such a high-level forum... wink
Average of ratings: -
In reply to Alejo Becerra Diaz

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Alejo,
This is a real problem which has not been solved yet in Moodle with the confusing way dates are treated in various languages. On my university Moodle site, for example, which is set to French, when I force language to English inside some of my courses, some dates appear in French, others in English. I have still not understood what this "locale" thing means, nor how to cope with this problem... My query dated Oct. 10th still waiting for an answer...
See screen dump which shows the confusion (using Moodle 1.5)
Joseph
Attachment Image1.jpg
In reply to Joseph Rézeau

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Alejo Becerra Diaz -
Well, yes, locale is the cause of your problems (AFAIK), but there is a design decision behind this problem that is what I'm asking for.
The solution to your problem I hope could be:
1) Goto Admin -> Configure -> Variables
2) Put "fra_fra" in the "locale" variable (fr_fr is OK in Linux and the like, but not in Windows)

You can get more information in this thread http://moodle.org/mod/forum/discuss.php?d=16893#82462
I hope this helps.
In reply to Joseph Rézeau

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Alejo and Martin,
Unfortunately the locale is not the only culprit in this matter. I have taken some winktime to do thorough testing and recorded the results in the following table.
case server locale user preferred language course force language interface calendar days calendar months logs result
1 Windows fr_FR (default) français français français français ENGLISH ENGLISH KO
2 Windows fr_FR français English English English English English OK
3 Windows fr_FR English English English English English English OK
4 Windows fr_FR English français français français ENGLISH ENGLISH KO
5 Windows fra_FRA français français français français français français OK
6 Windows fra_FRA français English English English English English OK
7 Windows fra_FRA English English English English English English OK
8 Windows fra_FRA English français français français ENGLISH ENGLISH KO
9 Linux fr_fr français français français français français français OK
10 Linux fr_fr français English English English français français KO
11 Linux fr_fr English English English English ENGLISH ENGLISH OK
12 Linux fr_fr English français français français français français OK

It is clear from this table that the behavior of the language settings in Moodle is buggy. We have problems (KO) as well on a Linux as a Windows server. We have problems when the user's preferred language is different from the course's forced language (and different from the site-wide's preferred language).
My present teaching situation is that of case #10: our university Moodle site uses Linux server, locale is set as fr_fr (French) and must remain like that; my students' default preferred language is French (most of their courses are in French); my English courses are set to forced language = English, and I get the mix-up in date & month names shown in the screen dump in my previous post.
Considering the extreme implication of Moodle towards customization in world languages, this bug should be considered serious, since it clearly undermines a consistent display of the Moodle interface - including calendar month names and log dates - to faculty and students.
Please Martin, can you find a quick solution? Why not use the PHP translation instead of the system one, if the latter leads to those bugs?
Joseph
In reply to Joseph Rézeau

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Alejo Becerra Diaz -
Hi Joseph
Yes, I see that you indeed did some testing.
I gave you my little advice for a simple, one-language-for-everything" instalation, but I had never take "course force language" into account.
At least it is clear that "fr_fr" is an erroneous configuration in Windows (it shows the "system related date & time information" (month names and logs), in the default english language.
I really think that taking month names from Moodle langs files is the most logical option (is the method used to show every other string, afaik, and would solve one of the most common problems in non-english installs), but it seems that it is technically advantageous the way it is (I don't really catch way; I'm waiting for a brief explanation of Martin or another one)

Greetings

Alejo
In reply to Joseph Rézeau

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

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
Nice table!  It's missing a column of what the dates look like elsewhere in Moodle such as in the forums or logs - I suspect they are OK.

The only bug I see here is specifically a bug in the calendar module ... it certainly needs looking into.  What is the bug number please?
In reply to Martin Dougiamas

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Martin,

I've reported this as Bug #4215.

The problem is not affecting only the calendar module but ALL modules (and there IS a column for logs in my table.

I do hope you can come up with a solution.smile

Joseph

In reply to Alejo Becerra Diaz

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

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
The answer is "for speed".  Converting lots of dates into using PHP and string files is significant calculation, but doing it via system functions is much faster.

A switch to choose between the two would be a good idea.
In reply to Martin Dougiamas

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

by Alejo Becerra Diaz -
I think that I don't understand you very well. Can you explain to me, briefly, how is the process to show the month name in the calendar, and why looking into Moodle's lang files for the traslation of the name, instead of showing the systems name, is cumbersome?
In reply to Alejo Becerra Diaz

Re: Simple question: Why did Moodle recover month names from the system instead of recovering it from the lang files?

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
Date format strings look like this:

$string['strftimedaydatetime'] = '%A, %d %B %Y, %I:%M %p';

Different languages have different orders, and use different components.

Times are stored in seconds since epoch (1st Jan 1970)... converting these to a date would involve something like this (and I'm not including the timezone calculations because these are handled in PHP for either case):
  1. Calculate English string for each component individually year, month, day, am/pm, etc ... in addition, we also need to calculate hours and minutes and seconds.
  2. Use the English string for each component to look up each component inside the long language files.
  3. Put all the bits together in the correct order by parsing the formatting string, including spaces, commas and other characters.
For pages like logs or forums with many dates, repeat, repeat and repeat.

All this would be in PHP, not in a fast compiled C program like the POSIX locale libraries.

Someone is very welcome to come up with a PHP function that will do all this and I'll make it an optional alternative! It's not trivial, though, and will slow your Moodle down.