son Posted July 2, 2009 Share Posted July 2, 2009 Although I set at begining of script:date_default_timezone_set('Europe/Berlin');all information I output for a calendar is in English. What else would I need to set?Son Link to comment Share on other sites More sharing options...
Ingolme Posted July 2, 2009 Share Posted July 2, 2009 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 More sharing options...
son Posted July 2, 2009 Author Share Posted July 2, 2009 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 More sharing options...
Ingolme Posted July 3, 2009 Share Posted July 3, 2009 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 More sharing options...
son Posted July 3, 2009 Author Share Posted July 3, 2009 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 More sharing options...
Ingolme Posted July 3, 2009 Share Posted July 3, 2009 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 More sharing options...
son Posted July 3, 2009 Author Share Posted July 3, 2009 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 More sharing options...
justsomeguy Posted July 3, 2009 Share Posted July 3, 2009 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. Link to comment Share on other sites More sharing options...
son Posted July 3, 2009 Author Share Posted July 3, 2009 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 More sharing options...
justsomeguy Posted July 3, 2009 Share Posted July 3, 2009 The str_replace line is correct, assuming the array is created. What does it echo? Link to comment Share on other sites More sharing options...
son Posted July 3, 2009 Author Share Posted July 3, 2009 The str_replace line is correct, assuming the array is created. What does it echo?It shows the name of the week day in English...Son Link to comment Share on other sites More sharing options...
Ingolme Posted July 4, 2009 Share Posted July 4, 2009 I used the str_ireplace() function so that it would be case insensitive. Link to comment Share on other sites More sharing options...
son Posted July 4, 2009 Author Share Posted July 4, 2009 I used the str_ireplace() function so that it would be case insensitive.Now I understand. Do you know why it does not work? Still cannot get it work...Son Link to comment Share on other sites More sharing options...
Ingolme Posted July 5, 2009 Share Posted July 5, 2009 Can you post the full script as you have it now? I probably will be able to see where there's a mistake. Link to comment Share on other sites More sharing options...
son Posted July 5, 2009 Author Share Posted July 5, 2009 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 More sharing options...
Ingolme Posted July 5, 2009 Share Posted July 5, 2009 Did you try using str_ireplace rather than str_replace? Link to comment Share on other sites More sharing options...
son Posted July 5, 2009 Author Share Posted July 5, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.