MyBB Community Forums

Full Version: MyBB date format not multilingual
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

the date format of MyBB cannot be changed to another language than english without core modifications. It says always Monday, Tuesday, January, February etc. no matter what language files you have installed.

Is this intended or has this been simply overlooked?

My date format is currently this: l, j. F Y

I want this format in all posts and the welcome back box, but it is in english only and remains in english Undecided
The names returned by the date function come from PHP, it's nothing to do with MyBB itself or its language packs. Make a PHP file with just this in it:

<?php
echo date('l, j. F Y');
?>

It will say 'Saturday, 7. April 2012', because that's the date PHP generates, the names don't come from the language files. To have this translated is a PHP configuration issue, beyond the reach of MyBB unless you want to start setting PHP configuration values based on the location of your visitors. MyBB already does this:

if(function_exists('date_default_timezone_set') && !ini_get('date.timezone'))
{
	date_default_timezone_set('GMT');
}

However as you can see it'll only do that if one isn't already set in your php.ini, and for MyBB to be able to change this on a user-by-user basis it'll have to resort to a 3rd party/external IP location lookup service. It's fully intentional that we don't do this.
Hm.. I see. Well on the bottom of the page a person can change the desired language of the board. In a perfect world this should be connected with the date format too imo. What is the point in MyBB having a multilingual function if the date format remains in english? Most people cannot code so they will inevitablely come across this issue :/
The purpose of the language system is to translate MyBB's text, which is what it does. As I said, MyBB doesn't produce the text that is in the dates, it is generated by PHP, so isn't something the language system can change because it's not coming from the language system to begin with. As for other people coming across the issue, I can't remember anybody else mentioning this since I've been here.

However, I'll look into how feasible it would be to do while we're developing 1.8. Looking at the docs though it requires totally different functions, isn't even just a case of setting the timezone.
Ok, thanks. According to the german MyBB support forum you have to replace for the names of the days this in the global.php:
$datenow = my_date($mybb->settings['dateformat'], TIME_NOW, '', false);

with this:
//$datenow = my_date($mybb->settings['dateformat'], TIME_NOW, '', false);
$wtage = array("Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag");
$wochentag = $wtage[date("w", TIME_NOW)];
$datenow = $wochentag.", ".my_date($mybb->settings['dateformat'], TIME_NOW, '', false); 

and change the date format in the ACP to this: j.F Y

For the names of the months you have to do something similar. This is however a permanent solution, so the consideration of adding a proper solution to MyBB 1.8 is appreciated Smile
Really MyBB should be using setlocale() and strftime() instead of date(), but this would require many, many edits throughout MyBB.
(2012-04-08, 09:16 AM)Nathan Malcolm Wrote: [ -> ]Really MyBB should be using setlocale() and strftime() instead of date(), but this would require many, many edits throughout MyBB.

Exactly what I was thinking, though it might cause problems with some hosts who don't have correct locales installed.
Yeah that's what I thought, probably isn't easy to change and compatibility issues. But will look into it closer soon.
Looking at the documentation for the setlocale() function, this doesn't seem safe on multi-threaded web servers. The current locale is stored per process, and not per thread. This means that if one request changes the current locale, it is changed for all requests.
(2012-04-09, 06:23 AM)laie_techie Wrote: [ -> ]Looking at the documentation for the setlocale() function, this doesn't seem safe on multi-threaded web servers. The current locale is stored per process, and not per thread. This means that if one request changes the current locale, it is changed for all requests.

Now THAT would mess up a forum clock.
Pages: 1 2