Ticket #2568: wp_locale.diff
| File wp_locale.diff, 16.9 KB (added by , 20 years ago) |
|---|
-
E:/PHP/WordPress/SVN/wp-includes/functions.php
16 16 } 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) ) { 22 22 return false; … … 29 29 if ( -1 == $i || false == $i ) 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->month[date('m', $i)]; 34 $datemonth_abbrev = $wp_locale->month_abbrev[$datemonth]; 35 $dateweekday = $wp_locale->weekday[date('w', $i)]; 36 $dateweekday_abbrev = $wp_locale->weekday_abbrev[$dateweekday]; 37 $datemeridiem = $wp_locale->meridiem[date('a', $i)]; 38 $datemeridiem_capital = $wp_locale->meridiem[date('A', $i)]; 37 39 $dateformatstring = ' '.$dateformatstring; 38 40 $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); 39 41 $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $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); 44 48 } … … 66 70 } 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->month[date('m', $i)]; 77 $datemonth_abbrev = $wp_locale->month_abbrev[$datemonth]; 78 $dateweekday = $wp_locale->weekday[date('w', $i)]; 79 $dateweekday_abbrev = $wp_locale->weekday_abbrev[$dateweekday]; 80 $datemeridiem = $wp_locale->meridiem[date('a', $i)]; 81 $datemeridiem_capital = $wp_locale->meridiem[date('A', $i)]; 76 82 $dateformatstring = ' '.$dateformatstring; 77 83 $dateformatstring = preg_replace("/([^\\\])D/", "\${1}".backslashit($dateweekday_abbrev), $dateformatstring); 78 84 $dateformatstring = preg_replace("/([^\\\])F/", "\${1}".backslashit($datemonth), $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) { 88 97 $my = substr($mysqlstring,0,4); -
E:/PHP/WordPress/SVN/wp-includes/locale.php
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 Meridiem 82 $this->meridiem['am'] = __('am'); 83 $this->meridiem['pm'] = __('pm'); 84 $this->meridiem['AM'] = __('AM'); 85 $this->meridiem['PM'] = __('PM'); 86 } 87 88 function WP_Locale() { 89 $this->init(); 90 } 68 91 } 69 92 70 93 ?> 94 No newline at end of file -
E:/PHP/WordPress/SVN/wp-includes/template-functions-general.php
134 134 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'); 140 140 $p = get_query_var('p'); … … 173 173 // If there's a month 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->month[substr($m, 4, 2)]; 177 177 $title = "$my_year $sep $my_month"; 178 178 } 179 179 180 180 if ( !empty($year) ) { 181 181 $title = $year; 182 182 if ( !empty($monthnum) ) 183 $title .= " $sep ".$ month[zeroise($monthnum, 2)];183 $title .= " $sep ".$wp_locale->month[zeroise($monthnum, 2)]; 184 184 if ( !empty($day) ) 185 185 $title .= " $sep ".zeroise($day, 2); 186 186 } … … 240 240 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->month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)]; 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->month[substr($m, 4, 2)]; 250 250 } 251 251 252 252 if ( !empty($my_month) && $display ) … … 292 292 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 ) 298 298 $type = 'monthly'; … … 330 330 foreach ( $arcresults as $arcresult ) { 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->month[zeroise($arcresult->month,2)], $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->month[zeroise($arcresult->month,2)], $arcresult->year); 337 337 } 338 338 echo get_archives_link($url, $text, $format, $before, $after); 339 339 } … … 394 394 395 395 396 396 function get_calendar($daylength = 1) { 397 global $wpdb, $m, $monthnum, $year, $timedifference, $ month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts;397 global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts; 398 398 399 399 // Quick check. If we have no posts at all, abort! 400 400 if ( !$posts ) { … … 450 450 LIMIT 1"); 451 451 452 452 echo '<table id="wp-calendar"> 453 <caption>' . $ month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>453 <caption>' . $wp_locale->month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption> 454 454 <thead> 455 455 <tr>'; 456 456 457 $day_abbrev = $w eekday_initial;457 $day_abbrev = $wp_locale->weekday_initial; 458 458 if ( $daylength > 1 ) 459 $day_abbrev = $w eekday_abbrev;459 $day_abbrev = $wp_locale->weekday_abbrev; 460 460 461 461 $myweek = array(); 462 462 463 463 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { 464 $myweek[]=$w eekday[($wdcount+$week_begins)%7];464 $myweek[]=$wp_locale->weekday[($wdcount+$week_begins)%7]; 465 465 } 466 466 467 467 foreach ( $myweek as $wd ) { … … 476 476 <tr>'; 477 477 478 478 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>';479 echo "\n\t\t".'<td abbr="' . $wp_locale->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'), $wp_locale->month[zeroise($previous->month, 2)], 481 date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $wp_locale->month_abbrev[$wp_locale->month[zeroise($previous->month, 2)]] . '</a></td>'; 482 482 } else { 483 483 echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; 484 484 } … … 486 486 echo "\n\t\t".'<td class="pad"> </td>'; 487 487 488 488 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>';489 echo "\n\t\t".'<td abbr="' . $wp_locale->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'), $wp_locale->month[zeroise($next->month, 2)], 491 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) . '">' . $wp_locale->month_abbrev[$wp_locale->month[zeroise($next->month, 2)]] . ' »</a></td>'; 492 492 } else { 493 493 echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; 494 494 } … … 675 675 676 676 677 677 function the_weekday() { 678 global $w eekday, $id, $post;679 $the_weekday = $w eekday[mysql2date('w', $post->post_date)];678 global $wp_locale, $id, $post; 679 $the_weekday = $wp_locale->weekday[mysql2date('w', $post->post_date)]; 680 680 $the_weekday = apply_filters('the_weekday', $the_weekday); 681 681 echo $the_weekday; 682 682 } 683 683 684 684 685 685 function the_weekday_date($before='',$after='') { 686 global $w eekday, $id, $post, $day, $previousweekday;686 global $wp_locale, $id, $post, $day, $previousweekday; 687 687 $the_weekday_date = ''; 688 688 if ( $day != $previousweekday ) { 689 689 $the_weekday_date .= $before; 690 $the_weekday_date .= $w eekday[mysql2date('w', $post->post_date)];690 $the_weekday_date .= $wp_locale->weekday[mysql2date('w', $post->post_date)]; 691 691 $the_weekday_date .= $after; 692 692 $previousweekday = $day; 693 693 } -
E:/PHP/WordPress/SVN/wp-settings.php
216 216 // Pull in locale data after loading text domain. 217 217 require_once(ABSPATH . WPINC . '/locale.php'); 218 218 219 $wp_locale = new WP_Locale(); 220 219 221 // Load functions for active theme. 220 222 if ( file_exists(TEMPLATEPATH . "/functions.php") ) 221 223 include(TEMPLATEPATH . "/functions.php");