Dates in Japanese

Dates in Japanese

by Paul Shew -
Number of replies: 2
I'm setting up a Moodle server to facilitate the courses I'll be teaching this coming academic year in Japan. I've found solutions to most problems I've come across, but the display of DATES is a problem.

I've set the locale to ja_JP.eucjp, so now they display in Japanese order, but it's still missing some characters.
Now, it displays like this: 4 2月 2003
It should display like this: 4日2月2003年

In Japanese, we don't need the spaces, but we do need the characters for day and year.

Is this a problem with settings on my server, or is it a problem with Moodle's code?

My server is still experimental, and I'm just learning how to use it, but here's the link: http://ac.shew.jp
Check NEWS to see an example.

I know that Martin is busy writing his dissertation, so I'm hoping someone else can help. wink
Average of ratings: -
In reply to Paul Shew

Re: Dates in Japanese

by Paul Shew -
Well, it's my first time to "look under the hood" so to speak, but I've made some progress.

I tracked down the function that defines the date string within /lib/mooodlelib.php.

I changed the following two lines of the userdate fuction from
$format      = "%A, %d %B %Y, %I:%M %p";
$formatnoday = "%A, DD %B %Y, %I:%M %p";
to
$format      = "%Y年%b%d日(%a) %H:%M";
$formatnoday = "%Y年%bDD日(%a) %H:%M";
I also wanted to use a 24 hour clock, so you'll notice that changed as well.

The character encoding is EUC.

NOTES: Both %b and %B produce the same format in Japanese(2月), which includes the character for month. %m results in the integer, which would make it consistant with the day and year, but it also includes the leading zero. So the simplest solution is to use %b or %B and then omit the character for month from the format. Since it's dependent upon the current locale set with setlocale(), I can't guarantee it will work on all systems.

You can see it on my site: ac.shew.jp
In reply to Paul Shew

Re: Dates in Japanese

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
I'm glad the hack for 1.0.8.1 is doing the trick for your site.

This whole issue has already been fixed properly (in CVS) by moving all the format strings out into the language packs.

For example, go to http://moodle.com and flip through the language menu up the top (and notice the date formats changing).

So rest assured that when the next release comes out you won't have to maintain your hack.

Cheers,
Martin