root/tags/1.3/wp-includes/locale.php

Revision 1069, 5.3 kB (checked in by donncha, 1 year ago)

Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439

  • Property svn:eol-style set to native
Line 
1 <?php
2
3 // Date and Time
4
5 class WP_Locale {
6     var $weekday;
7     var $weekday_initial;
8     var $weekday_abbrev;
9
10     var $month;
11     var $month_abbrev;
12
13     var $meridiem;
14
15     var $text_direction = 'ltr';
16     var $locale_vars = array('text_direction');
17
18     function init() {
19         // The Weekdays
20         $this->weekday[0] = __('Sunday');
21         $this->weekday[1] = __('Monday');
22         $this->weekday[2] = __('Tuesday');
23         $this->weekday[3] = __('Wednesday');
24         $this->weekday[4] = __('Thursday');
25         $this->weekday[5] = __('Friday');
26         $this->weekday[6] = __('Saturday');
27
28         // The first letter of each day.  The _%day%_initial suffix is a hack to make
29         // sure the day initials are unique.
30         $this->weekday_initial[__('Sunday')]    = __('S_Sunday_initial');
31         $this->weekday_initial[__('Monday')]    = __('M_Monday_initial');
32         $this->weekday_initial[__('Tuesday')]   = __('T_Tuesday_initial');
33         $this->weekday_initial[__('Wednesday')] = __('W_Wednesday_initial');
34         $this->weekday_initial[__('Thursday')]  = __('T_Thursday_initial');
35         $this->weekday_initial[__('Friday')]    = __('F_Friday_initial');
36         $this->weekday_initial[__('Saturday')]  = __('S_Saturday_initial');
37
38         foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
39             $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
40         }
41
42         // Abbreviations for each day.
43         $this->weekday_abbrev[__('Sunday')]    = __('Sun');
44         $this->weekday_abbrev[__('Monday')]    = __('Mon');
45         $this->weekday_abbrev[__('Tuesday')]   = __('Tue');
46         $this->weekday_abbrev[__('Wednesday')] = __('Wed');
47         $this->weekday_abbrev[__('Thursday')]  = __('Thu');
48         $this->weekday_abbrev[__('Friday')]    = __('Fri');
49         $this->weekday_abbrev[__('Saturday')]  = __('Sat');
50
51         // The Months
52         $this->month['01'] = __('January');
53         $this->month['02'] = __('February');
54         $this->month['03'] = __('March');
55         $this->month['04'] = __('April');
56         $this->month['05'] = __('May');
57         $this->month['06'] = __('June');
58         $this->month['07'] = __('July');
59         $this->month['08'] = __('August');
60         $this->month['09'] = __('September');
61         $this->month['10'] = __('October');
62         $this->month['11'] = __('November');
63         $this->month['12'] = __('December');
64
65         // Abbreviations for each month. Uses the same hack as above to get around the
66         // 'May' duplication.
67         $this->month_abbrev[__('January')] = __('Jan_January_abbreviation');
68         $this->month_abbrev[__('February')] = __('Feb_February_abbreviation');
69         $this->month_abbrev[__('March')] = __('Mar_March_abbreviation');
70         $this->month_abbrev[__('April')] = __('Apr_April_abbreviation');
71         $this->month_abbrev[__('May')] = __('May_May_abbreviation');
72         $this->month_abbrev[__('June')] = __('Jun_June_abbreviation');
73         $this->month_abbrev[__('July')] = __('Jul_July_abbreviation');
74         $this->month_abbrev[__('August')] = __('Aug_August_abbreviation');
75         $this->month_abbrev[__('September')] = __('Sep_September_abbreviation');
76         $this->month_abbrev[__('October')] = __('Oct_October_abbreviation');
77         $this->month_abbrev[__('November')] = __('Nov_November_abbreviation');
78         $this->month_abbrev[__('December')] = __('Dec_December_abbreviation');
79
80         foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
81             $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
82         }
83
84         // The Meridiems
85         $this->meridiem['am'] = __('am');
86         $this->meridiem['pm'] = __('pm');
87         $this->meridiem['AM'] = __('AM');
88         $this->meridiem['PM'] = __('PM');
89
90         // Numbers formatting
91         // See http://php.net/number_format
92
93         $trans = _c('number_format_decimals|$decimals argument for http://php.net/number_format, default is 0');
94         $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
95
96         $trans = _c('number_format_decimal_point|$dec_point argument for http://php.net/number_format, default is .');
97         $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
98
99         $trans = _c('number_format_thousands_sep|$thousands_sep argument for http://php.net/number_format, default is ,');
100         $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
101
102         // Import global locale vars set during inclusion of $locale.php.
103         foreach ( $this->locale_vars as $var ) {
104             if ( isset($GLOBALS[$var]) )
105                 $this->$var = $GLOBALS[$var];
106         }
107
108     }
109
110     function get_weekday($weekday_number) {
111         return $this->weekday[$weekday_number];
112     }
113
114     function get_weekday_initial($weekday_name) {
115         return $this->weekday_initial[$weekday_name];
116     }
117
118     function get_weekday_abbrev($weekday_name) {
119         return $this->weekday_abbrev[$weekday_name];
120     }
121
122     function get_month($month_number) {
123         return $this->month[zeroise($month_number, 2)];
124     }
125
126     function get_month_initial($month_name) {
127         return $this->month_initial[$month_name];
128     }
129
130     function get_month_abbrev($month_name) {
131         return $this->month_abbrev[$month_name];
132     }
133
134     function get_meridiem($meridiem) {
135         return $this->meridiem[$meridiem];
136     }
137
138     // Global variables are deprecated. For backwards compatibility only.
139     function register_globals() {
140         $GLOBALS['weekday']         = $this->weekday;
141         $GLOBALS['weekday_initial'] = $this->weekday_initial;
142         $GLOBALS['weekday_abbrev']  = $this->weekday_abbrev;
143         $GLOBALS['month']           = $this->month;
144         $GLOBALS['month_abbrev']    = $this->month_abbrev;
145     }
146
147     function WP_Locale() {
148         $this->init();
149         $this->register_globals();
150     }
151 }
152
153 ?>
154
Note: See TracBrowser for help on using the browser.