Jump to content

Timezone And Language


son
 Share

Recommended Posts

The time zone and language of your site have nothing to do with eachother. If you want your site in German, write your content in German; If you want your site in French, write your content in French.

Link to comment
Share on other sites

The time zone and language of your site have nothing to do with eachother. If you want your site in German, write your content in German; If you want your site in French, write your content in French.
I work with the timestamp varible and have never specified the words as such. What do you mean by write content in relevant language?Son
Link to comment
Share on other sites

I haven't really understood your initial question. You seem to be relating timezones to languages.

all information I output for a calendar is in English. What else would I need to set?
Link to comment
Share on other sites

I haven't really understood your initial question. You seem to be relating timezones to languages.
I display the date as:echo date('l, d.m.Y', $timestamp);and created an array for German names of all months as:$month_names = array("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");but how do I combine the two? How can i make 'l' display the relevant name from $month_names array?Son
Link to comment
Share on other sites

You'll have to replace the names in the resulting string.The following example makes use of the array_keys() and array_values() functions to avoid having to create two arrays for the replacements.

$month_names = array(  'January'=>'Januar',  'February'=>'Februar',  'March'=>'März',  'April'=>'April',  'May'=>'Mai',  'June'=>'Juni',  'July'=>'Juli',  'August'=>'August',  'September'=>'September',  'October'=>'Oktober',  'November'=>'November',  'December'=>'Dezember');$x = date("l",$time);$x = str_ireplace(array_keys($month_names),$array_values($month_names),$x);

Link to comment
Share on other sites

Having the month array and using:

$x = date("l",$timestamp);$x = str_ireplace(array_keys($month_names),$array_values($month_names),$x);echo $x;

brings up two errors:Notice: Undefined variable: array_valuesFatal error: Function name must be a stringThis regards line:$x = str_ireplace(array_keys($month_names),$array_values($month_names),$x);Also how do I combine this with the date? Would like not only to display the name of the week...Son

Link to comment
Share on other sites

Small typo, remove the $ in front of array_values.

Also how do I combine this with the date? Would like not only to display the name of the week...
Put everything you want to replace in the array, it doesn't only need to be month names, it can be any translation. Edited by justsomeguy
Link to comment
Share on other sites

Small typo, remove the $ in front of array_values.Put everything you want to replace in the array, it doesn't only need to be month names, it can be any translation.
Althought I also corrected the type str_replace it still does not show German words. I have it as:
$x = date("l",$timestamp);$x = str_replace(array_keys($month_names),array_values($month_names),$x);echo $x;

Why could that be?Son

Link to comment
Share on other sites

Can you post the full script as you have it now? I probably will be able to see where there's a mistake.
Many thanks...
// view definitionsdefine('DAY_HR_START', 9);define('DAY_HR_END', 17);// German month name array$month_names = array(  'January'=>'Januar',  'February'=>'Februar',  'March'=>'März',  'April'=>'April',  'May'=>'Mai',  'June'=>'Juni',  'July'=>'Juli',  'August'=>'August',  'September'=>'September',  'October'=>'Oktober',  'November'=>'November',  'December'=>'Dezember');// accept incoming URL parameter$timestamp = (isset($_GET['t'])) ? $_GET['t'] : time();// determine useful aspects of the requested monthlist($month, $day, $year) = explode('/', date('m/d/Y', $timestamp));$first_day_of_month = date('w', mktime(0, 0, 0, $month, 1, $year));$total_days = date('t', $timestamp);// add new eventif (isset($_POST['submitted'])){    // validate incoming values    $evt_name = (isset($_POST['evt_name'])) ? $_POST['evt_name'] : '';    $evt_name = trim($evt_name);    if (!$evt_name)    {        $evt_name = 'none';    }    $evt_hour = (isset($_POST['evt_hour'])) ? (int)$_POST['evt_hour'] : 0;    $evt_min = (isset($_POST['evt_min'])) ? (int)$_POST['evt_min'] : 0;    $evt_notify = (isset($_POST['evt_notify']) && $_POST['evt_notify'] == 'yes');    // add to database    $query = sprintf('INSERT INTO %scalendar (EVENT_NAME, EVENT_TSTAMP, ' .         'NOTIFY) VALUES ("%s", "%04d-%02d-%02d %02d:%02d:00", %d)',        DB_TBL_PREFIX,        mysql_real_escape_string($evt_name, $GLOBALS['DB']),        $year, $month, $day,        $evt_hour, $evt_min,        $evt_notify);    mysql_query($query, $GLOBALS['DB']);}// output table headerob_start();echo '<table id="day_calendar">';echo '<tr id="day_calendar_header"><th colspan="2">';echo '<a href="'. htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' .    strtotime('-1 day', $timestamp) . '"><</a>  ';$x = date("l",$timestamp);$x = str_replace(array_keys($month_names),array_values($month_names),$x);echo $x;echo '  <a href="'. htmlspecialchars($_SERVER['PHP_SELF']) . '?t=' .    strtotime('+1 day', $timestamp) . '">></a>';echo '</th></tr>';

Son

Link to comment
Share on other sites

Did you try using str_ireplace rather than str_replace?
I found the error just now and cannot believe I did not notice this before. The array contains month names, but I tried to 'translate' week days ($x = date("l",$timestamp):)...Son
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...