Changeset 3676
- Timestamp:
- 04/02/2006 12:20:11 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r3672 r3676 970 970 971 971 function touch_time($edit = 1, $for_post = 1) { 972 global $ month, $post, $comment;972 global $wp_locale, $post, $comment; 973 973 974 974 if ( $for_post ) … … 990 990 echo "\t\t\t<option value=\"$i\""; 991 991 if ($i == $mm) 992 echo " selected='selected'"; 993 if ($i < 10) { 994 $ii = "0".$i; 995 } else { 996 $ii = "$i"; 997 } 998 echo ">".$month["$ii"]."</option>\n"; 992 echo ' selected="selected"'; 993 echo '>' . $wp_locale->get_month($i) . "</option>\n"; 999 994 } 1000 995 ?> … … 1008 1003 if ( $edit ) { 1009 1004 _e('Existing timestamp'); 1010 echo ": {$month[$mm]} $jj, $aa @ $hh:$mn"; 1005 //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn"; 1006 echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn); 1011 1007 } 1012 1008 ?> -
trunk/wp-admin/edit.php
r3671 r3676 94 94 $arc_year = $arc_row->yyear; 95 95 $arc_month = $arc_row->mmonth; 96 97 if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] ) 96 $arc_month = zeroise($arc_month, 2); 97 98 if( isset($_GET['m']) && $arc_year . $arc_month == (int) $_GET['m'] ) 98 99 $default = 'selected="selected"'; 99 100 else 100 101 $default = null; 101 102 102 echo "<option $default value=\"" . $arc_year .zeroise($arc_month, 2). '">';103 echo $ month[zeroise($arc_month, 2)]. " $arc_year";103 echo "<option $default value=\"" . $arc_year . $arc_month . '">'; 104 echo $wp_locale->get_month($arc_month) . " $arc_year"; 104 105 echo "</option>\n"; 105 106 } -
trunk/wp-admin/options-general.php
r3548 r3676 95 95 <?php 96 96 for ($day_index = 0; $day_index <= 6; $day_index++) : 97 if ($day_index == get_settings('start_of_week')) $selected = " selected='selected'"; 98 else $selected = ''; 99 echo "\n\t<option value='$day_index' $selected>$weekday[$day_index]</option>"; 97 $selected = (get_settings('start_of_week') == $day_index) ? 'selected="selected"' : ''; 98 echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>'; 100 99 endfor; 101 100 ?> -
trunk/wp-includes/functions.php
r3670 r3676 17 17 18 18 function mysql2date($dateformatstring, $mysqlstring, $translate = true) { 19 global $ month, $weekday, $month_abbrev, $weekday_abbrev;19 global $wp_locale; 20 20 $m = $mysqlstring; 21 21 if ( empty($m) ) { … … 30 30 $i = 0; 31 31 32 if ( !empty($month) && !empty($weekday) && $translate ) { 33 $datemonth = $month[date('m', $i)]; 34 $datemonth_abbrev = $month_abbrev[$datemonth]; 35 $dateweekday = $weekday[date('w', $i)]; 36 $dateweekday_abbrev = $weekday_abbrev[$dateweekday]; 32 if ( !empty($wp_locale->month) && !empty($wp_locale->weekday) && $translate ) { 33 $datemonth = $wp_locale->get_month(date('m', $i)); 34 $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth); 35 $dateweekday = $wp_locale->get_weekday(date('w', $i)); 36 $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday); 37 $datemeridiem = $wp_locale->get_meridiem(date('a', $i)); 38 $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i)); 37 39 $dateformatstring = ' '.$dateformatstring; 38 40 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring); … … 40 42 $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring); 41 43 $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring); 44 $dateformatstring = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring); 45 $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring); 42 46 43 47 $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); … … 67 71 68 72 function date_i18n($dateformatstring, $unixtimestamp) { 69 global $ month, $weekday, $month_abbrev, $weekday_abbrev;73 global $wp_locale; 70 74 $i = $unixtimestamp; 71 if ( (!empty($month)) && (!empty($weekday)) ) { 72 $datemonth = $month[date('m', $i)]; 73 $datemonth_abbrev = $month_abbrev[$datemonth]; 74 $dateweekday = $weekday[date('w', $i)]; 75 $dateweekday_abbrev = $weekday_abbrev[$dateweekday]; 75 if ( (!empty($wp_locale->month)) && (!empty($wp_locale->weekday)) ) { 76 $datemonth = $wp_locale->get_month(date('m', $i)); 77 $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth); 78 $dateweekday = $wp_locale->get_weekday(date('w', $i)); 79 $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday); 80 $datemeridiem = $wp_locale->get_meridiem(date('a', $i)); 81 $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i)); 76 82 $dateformatstring = ' '.$dateformatstring; 77 83 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring); … … 79 85 $dateformatstring = preg_replace("/([^\\\])l/", "\${1}".backslashit($dateweekday), $dateformatstring); 80 86 $dateformatstring = preg_replace("/([^\\\])M/", "\${1}".backslashit($datemonth_abbrev), $dateformatstring); 87 $dateformatstring = preg_replace("/([^\\\])a/", "\${1}".backslashit($datemeridiem), $dateformatstring); 88 $dateformatstring = preg_replace("/([^\\\])A/", "\${1}".backslashit($datemeridiem_capital), $dateformatstring); 89 81 90 $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); 82 91 } 83 92 $j = @date($dateformatstring, $i); 84 93 return $j; 85 94 } 86 95 87 96 function get_weekstartend($mysqlstring, $start_of_week) { -
trunk/wp-includes/locale.php
r2232 r3676 1 1 <?php 2 2 3 // Date and Time 3 4 4 // The Weekdays 5 $weekday[0] = __('Sunday'); 6 $weekday[1] = __('Monday'); 7 $weekday[2] = __('Tuesday'); 8 $weekday[3] = __('Wednesday'); 9 $weekday[4] = __('Thursday'); 10 $weekday[5] = __('Friday'); 11 $weekday[6] = __('Saturday'); 5 class WP_Locale { 6 var $weekday; 7 var $weekday_initial; 8 var $weekday_abbrev; 12 9 13 // The first letter of each day. The _%day%_initial suffix is a hack to make 14 // sure the day initials are unique. They should be translated to a one 15 // letter initial. 16 $weekday_initial[__('Sunday')] = __('S_Sunday_initial'); 17 $weekday_initial[__('Monday')] = __('M_Monday_initial'); 18 $weekday_initial[__('Tuesday')] = __('T_Tuesday_initial'); 19 $weekday_initial[__('Wednesday')] = __('W_Wednesday_initial'); 20 $weekday_initial[__('Thursday')] = __('T_Thursday_initial'); 21 $weekday_initial[__('Friday')] = __('F_Friday_initial'); 22 $weekday_initial[__('Saturday')] = __('S_Saturday_initial'); 10 var $month; 11 var $month_abbrev; 23 12 24 foreach ($weekday_initial as $weekday_ => $weekday_initial_) { 25 $weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_); 26 } 13 var $meridiem; 27 14 28 // Abbreviations for each day. 29 $weekday_abbrev[__('Sunday')] = __('Sun'); 30 $weekday_abbrev[__('Monday')] = __('Mon'); 31 $weekday_abbrev[__('Tuesday')] = __('Tue'); 32 $weekday_abbrev[__('Wednesday')] = __('Wed'); 33 $weekday_abbrev[__('Thursday')] = __('Thu'); 34 $weekday_abbrev[__('Friday')] = __('Fri'); 35 $weekday_abbrev[__('Saturday')] = __('Sat'); 15 function init() { 16 // The Weekdays 17 $this->weekday[0] = __('Sunday'); 18 $this->weekday[1] = __('Monday'); 19 $this->weekday[2] = __('Tuesday'); 20 $this->weekday[3] = __('Wednesday'); 21 $this->weekday[4] = __('Thursday'); 22 $this->weekday[5] = __('Friday'); 23 $this->weekday[6] = __('Saturday'); 36 24 37 // The Months 38 $month['01'] = __('January'); 39 $month['02'] = __('February'); 40 $month['03'] = __('March'); 41 $month['04'] = __('April'); 42 $month['05'] = __('May'); 43 $month['06'] = __('June'); 44 $month['07'] = __('July'); 45 $month['08'] = __('August'); 46 $month['09'] = __('September'); 47 $month['10'] = __('October'); 48 $month['11'] = __('November'); 49 $month['12'] = __('December'); 25 // The first letter of each day. The _%day%_initial suffix is a hack to make 26 // sure the day initials are unique. 27 $this->weekday_initial[__('Sunday')] = __('S_Sunday_initial'); 28 $this->weekday_initial[__('Monday')] = __('M_Monday_initial'); 29 $this->weekday_initial[__('Tuesday')] = __('T_Tuesday_initial'); 30 $this->weekday_initial[__('Wednesday')] = __('W_Wednesday_initial'); 31 $this->weekday_initial[__('Thursday')] = __('T_Thursday_initial'); 32 $this->weekday_initial[__('Friday')] = __('F_Friday_initial'); 33 $this->weekday_initial[__('Saturday')] = __('S_Saturday_initial'); 50 34 51 // Abbreviations for each month. Uses the same hack as above to get around the 52 // 'May' duplication. 53 $month_abbrev[__('January')] = __('Jan_January_abbreviation'); 54 $month_abbrev[__('February')] = __('Feb_February_abbreviation'); 55 $month_abbrev[__('March')] = __('Mar_March_abbreviation'); 56 $month_abbrev[__('April')] = __('Apr_April_abbreviation'); 57 $month_abbrev[__('May')] = __('May_May_abbreviation'); 58 $month_abbrev[__('June')] = __('Jun_June_abbreviation'); 59 $month_abbrev[__('July')] = __('Jul_July_abbreviation'); 60 $month_abbrev[__('August')] = __('Aug_August_abbreviation'); 61 $month_abbrev[__('September')] = __('Sep_September_abbreviation'); 62 $month_abbrev[__('October')] = __('Oct_October_abbreviation'); 63 $month_abbrev[__('November')] = __('Nov_November_abbreviation'); 64 $month_abbrev[__('December')] = __('Dec_December_abbreviation'); 35 foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) { 36 $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_); 37 } 65 38 66 foreach ($month_abbrev as $month_ => $month_abbrev_) { 67 $month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_); 39 // Abbreviations for each day. 40 $this->weekday_abbrev[__('Sunday')] = __('Sun'); 41 $this->weekday_abbrev[__('Monday')] = __('Mon'); 42 $this->weekday_abbrev[__('Tuesday')] = __('Tue'); 43 $this->weekday_abbrev[__('Wednesday')] = __('Wed'); 44 $this->weekday_abbrev[__('Thursday')] = __('Thu'); 45 $this->weekday_abbrev[__('Friday')] = __('Fri'); 46 $this->weekday_abbrev[__('Saturday')] = __('Sat'); 47 48 // The Months 49 $this->month['01'] = __('January'); 50 $this->month['02'] = __('February'); 51 $this->month['03'] = __('March'); 52 $this->month['04'] = __('April'); 53 $this->month['05'] = __('May'); 54 $this->month['06'] = __('June'); 55 $this->month['07'] = __('July'); 56 $this->month['08'] = __('August'); 57 $this->month['09'] = __('September'); 58 $this->month['10'] = __('October'); 59 $this->month['11'] = __('November'); 60 $this->month['12'] = __('December'); 61 62 // Abbreviations for each month. Uses the same hack as above to get around the 63 // 'May' duplication. 64 $this->month_abbrev[__('January')] = __('Jan_January_abbreviation'); 65 $this->month_abbrev[__('February')] = __('Feb_February_abbreviation'); 66 $this->month_abbrev[__('March')] = __('Mar_March_abbreviation'); 67 $this->month_abbrev[__('April')] = __('Apr_April_abbreviation'); 68 $this->month_abbrev[__('May')] = __('May_May_abbreviation'); 69 $this->month_abbrev[__('June')] = __('Jun_June_abbreviation'); 70 $this->month_abbrev[__('July')] = __('Jul_July_abbreviation'); 71 $this->month_abbrev[__('August')] = __('Aug_August_abbreviation'); 72 $this->month_abbrev[__('September')] = __('Sep_September_abbreviation'); 73 $this->month_abbrev[__('October')] = __('Oct_October_abbreviation'); 74 $this->month_abbrev[__('November')] = __('Nov_November_abbreviation'); 75 $this->month_abbrev[__('December')] = __('Dec_December_abbreviation'); 76 77 foreach ($this->month_abbrev as $month_ => $month_abbrev_) { 78 $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_); 79 } 80 81 // The Meridiems 82 $this->meridiem['am'] = __('am'); 83 $this->meridiem['pm'] = __('pm'); 84 $this->meridiem['AM'] = __('AM'); 85 $this->meridiem['PM'] = __('PM'); 86 } 87 88 function get_weekday($weekday_number) { 89 return $this->weekday[$weekday_number]; 90 } 91 92 function get_weekday_initial($weekday_name) { 93 return $this->weekday_initial[$weekday_name]; 94 } 95 96 function get_weekday_abbrev($weekday_name) { 97 return $this->weekday_abbrev[$weekday_name]; 98 } 99 100 function get_month($month_number) { 101 return $this->month[zeroise($month_number, 2)]; 102 } 103 104 function get_month_initial($month_name) { 105 return $this->month_initial[$month_name]; 106 } 107 108 function get_month_abbrev($month_name) { 109 return $this->month_abbrev[$month_name]; 110 } 111 112 function get_meridiem($meridiem) { 113 return $this->meridiem[$meridiem]; 114 } 115 116 // Global variables are deprecated. For backwards compatibility only. 117 function register_globals() { 118 $GLOBALS['weekday'] = $this->weekday; 119 $GLOBALS['weekday_initial'] = $this->weekday_initial; 120 $GLOBALS['weekday_abbrev'] = $this->weekday_abbrev; 121 $GLOBALS['month'] = $this->month; 122 $GLOBALS['month_abbrev'] = $this->month_abbrev; 123 } 124 125 function WP_Locale() { 126 $this->init(); 127 $this->register_globals(); 128 } 68 129 } 69 130 -
trunk/wp-includes/template-functions-general.php
r3566 r3676 135 135 function wp_title($sep = '»', $display = true) { 136 136 global $wpdb; 137 global $m, $year, $monthnum, $day, $category_name, $ month, $posts;137 global $m, $year, $monthnum, $day, $category_name, $wp_locale, $posts; 138 138 139 139 $cat = get_query_var('cat'); … … 174 174 if ( !empty($m) ) { 175 175 $my_year = substr($m, 0, 4); 176 $my_month = $ month[substr($m, 4, 2)];176 $my_month = $wp_locale->get_month($m); 177 177 $title = "$my_year $sep $my_month"; 178 178 } … … 181 181 $title = $year; 182 182 if ( !empty($monthnum) ) 183 $title .= " $sep ".$ month[zeroise($monthnum, 2)];183 $title .= " $sep ".$wp_locale->get_month($monthnum); 184 184 if ( !empty($day) ) 185 185 $title .= " $sep ".zeroise($day, 2); … … 241 241 242 242 function single_month_title($prefix = '', $display = true ) { 243 global $m, $monthnum, $ month, $year;243 global $m, $monthnum, $wp_locale, $year; 244 244 if ( !empty($monthnum) && !empty($year) ) { 245 245 $my_year = $year; 246 $my_month = $ month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];246 $my_month = $wp_locale->get_month($monthnum); 247 247 } elseif ( !empty($m) ) { 248 248 $my_year = substr($m, 0, 4); 249 $my_month = $ month[substr($m, 4, 2)];249 $my_month = $wp_locale->get_month($m); 250 250 } 251 251 … … 293 293 294 294 function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { 295 global $ month, $wpdb;295 global $wp_locale, $wpdb; 296 296 297 297 if ( '' == $type ) … … 331 331 $url = get_month_link($arcresult->year, $arcresult->month); 332 332 if ( $show_post_count ) { 333 $text = sprintf('%s %d', $ month[zeroise($arcresult->month,2)], $arcresult->year);333 $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year); 334 334 $after = ' ('.$arcresult->posts.')' . $afterafter; 335 335 } else { 336 $text = sprintf('%s %d', $ month[zeroise($arcresult->month,2)], $arcresult->year);336 $text = sprintf('%s %d', $wp_locale->get_month($arcresult->month), $arcresult->year); 337 337 } 338 338 echo get_archives_link($url, $text, $format, $before, $after); … … 394 394 395 395 396 function get_calendar($ daylength = 1) {397 global $wpdb, $m, $monthnum, $year, $timedifference, $ month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;396 function get_calendar($initial = true) { 397 global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts; 398 398 399 399 // Quick check. If we have no posts at all, abort! … … 451 451 452 452 echo '<table id="wp-calendar"> 453 <caption>' . $ month[zeroise($thismonth, 2)]. ' ' . date('Y', $unixmonth) . '</caption>453 <caption>' . $wp_locale->get_month($thismonth) . ' ' . date('Y', $unixmonth) . '</caption> 454 454 <thead> 455 455 <tr>'; 456 456 457 $day_abbrev = $weekday_initial;458 if ( $daylength > 1 )459 $day_abbrev = $weekday_abbrev;460 461 457 $myweek = array(); 462 458 463 459 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { 464 $myweek[] =$weekday[($wdcount+$week_begins)%7];460 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); 465 461 } 466 462 467 463 foreach ( $myweek as $wd ) { 468 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>'; 464 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); 465 echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">$day_name</th>"; 469 466 } 470 467 … … 477 474 478 475 if ( $previous ) { 479 echo "\n\t\t".'<td abbr="' . $ month[zeroise($previous->month, 2)]. '" colspan="3" id="prev"><a href="' .480 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $ month[zeroise($previous->month, 2)],481 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $ month_abbrev[$month[zeroise($previous->month, 2)]]. '</a></td>';476 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . 477 get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), 478 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>'; 482 479 } else { 483 480 echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; … … 487 484 488 485 if ( $next ) { 489 echo "\n\t\t".'<td abbr="' . $ month[zeroise($next->month, 2)]. '" colspan="3" id="next"><a href="' .490 get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $ month[zeroise($next->month, 2)],491 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $ month_abbrev[$month[zeroise($next->month, 2)]]. ' »</a></td>';486 echo "\n\t\t".'<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . 487 get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), 488 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; 492 489 } else { 493 490 echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; … … 676 673 677 674 function the_weekday() { 678 global $w eekday, $id, $post;679 $the_weekday = $w eekday[mysql2date('w', $post->post_date)];675 global $wp_locale, $id, $post; 676 $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date)); 680 677 $the_weekday = apply_filters('the_weekday', $the_weekday); 681 678 echo $the_weekday; … … 684 681 685 682 function the_weekday_date($before='',$after='') { 686 global $w eekday, $id, $post, $day, $previousweekday;683 global $wp_locale, $id, $post, $day, $previousweekday; 687 684 $the_weekday_date = ''; 688 685 if ( $day != $previousweekday ) { 689 686 $the_weekday_date .= $before; 690 $the_weekday_date .= $w eekday[mysql2date('w', $post->post_date)];687 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date)); 691 688 $the_weekday_date .= $after; 692 689 $previousweekday = $day; -
trunk/wp-settings.php
r3670 r3676 215 215 require_once(ABSPATH . WPINC . '/locale.php'); 216 216 217 $wp_locale = new WP_Locale(); 218 217 219 // Load functions for active theme. 218 220 if ( file_exists(TEMPLATEPATH . "/functions.php") )
Note: See TracChangeset
for help on using the changeset viewer.