Page 1 of 1

Date display depending upon language settings

Posted: Wed Jun 09, 2004 2:02 am
by steedvlx
Hi, I have a site that I'm trying to integrate with the phpbb forums. This is itself is irrelevant but will explain a lot of the implanted code I will be talking about. :)

Right now, we only have two languages... Japanese and English. What I want to do is to display Japanese formatted dates on those pages.

e.g. Wednesday, June 9 >>>> (Japanese Date Text)6月 9日(水曜日)

I have contemplated arrays, although I really don't know how to use them. I have contemplated just storing the values in the database, but, I'm not sure if that is the best way. (3 DB accesses per page load).

Right now, I have a little routine that looks like this. I'm trying to convert the output to japanese. The date function is a straightforward assignment right now which is perfect for English. [ (date("l, F d",$last_visited) ] But, for japanese...What to do?

Code: Select all

<?php
//
// This code must be included in each page requiring user authorization to access
//
define('IN_PHPBB', true);
$phpbb_root_path = '../forums/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

// Check for logged in status and set some non-forum specific environment stuff
//
if($userdata['session_logged_in'])
	{
		$last_visited = $userdata['user_lastvisit'];
		$display_message = ('Welcome ' . $userdata['username'] . '! ' . '&#12354;&#12394;&#12383;&#12364;&#26368;&#24460;&#12398;&#26469;&#12425;&#12428;&#12383;&#12398;&#12399; ' . date("l, F d",$last_visited) . ' &#12391;&#12377;&#12290;');
		$site_root = ('http://www.chirowebjapan.com');
		$forum_index = ($site_root . '/forums/index.php?sid=' . $userdata['session_id']);
		$forum_logout_path = ($site_root . '/forums/login.php?logout=true&sid=' . $userdata['session_id']);
		$user_new_message = $userdata['user_new_privmsg'];
		$user_ip = $userdata['session_ip'];
		$display_logout_btn = ('TRUE');
	}
else
	{ 
		$display_message = ('Welcome to Chiroweb Japan. You are logged in as a Guest. Today is ' . gmdate("l. F d") . '.');
		$site_root = ('http://www.chirowebjapan.com');
		$forum_index = ($site_root . '/forums/index.php');
		$display_logout_btn = ('FALSE');
	}
?>
I'm just looking for some suggestions on what is the best way to go. Not, someone to write my code for me... Unless you just want to that is. :D

So, what do you think?

SteedVLX

I may be in more trouble than I thought. On preview, the Japanese above is converted to unicode values rather than the actual text. Hmmm.

Posted: Wed Jun 09, 2004 8:06 pm
by Weirdan
have you tried:

Code: Select all

setlocale(LC_ALL, 'ja_JP');
echo strftime('%c', $last_visited);

Posted: Wed Jun 09, 2004 8:47 pm
by steedvlx
I've never seen that before. And, it's not in the manual I have here with me. I'll search for it in the docs and read up.

If it's what I think it is, that will be a very handy function indeed. We plan to add more languages when all of this is done.

Thanks,
I'll let you know how it comes out. :)

SteedVLX