121 * specific calendar names and text direction. |
113 * specific calendar names and text direction. |
122 * |
114 * |
123 * @since 2.1.0 |
115 * @since 2.1.0 |
124 * |
116 * |
125 * @global string $text_direction |
117 * @global string $text_direction |
|
118 * @global string $wp_version |
126 */ |
119 */ |
127 public function init() { |
120 public function init() { |
128 // The Weekdays |
121 // The Weekdays |
129 $this->weekday[0] = /* translators: weekday */ __('Sunday'); |
122 $this->weekday[0] = /* translators: weekday */ __( 'Sunday' ); |
130 $this->weekday[1] = /* translators: weekday */ __('Monday'); |
123 $this->weekday[1] = /* translators: weekday */ __( 'Monday' ); |
131 $this->weekday[2] = /* translators: weekday */ __('Tuesday'); |
124 $this->weekday[2] = /* translators: weekday */ __( 'Tuesday' ); |
132 $this->weekday[3] = /* translators: weekday */ __('Wednesday'); |
125 $this->weekday[3] = /* translators: weekday */ __( 'Wednesday' ); |
133 $this->weekday[4] = /* translators: weekday */ __('Thursday'); |
126 $this->weekday[4] = /* translators: weekday */ __( 'Thursday' ); |
134 $this->weekday[5] = /* translators: weekday */ __('Friday'); |
127 $this->weekday[5] = /* translators: weekday */ __( 'Friday' ); |
135 $this->weekday[6] = /* translators: weekday */ __('Saturday'); |
128 $this->weekday[6] = /* translators: weekday */ __( 'Saturday' ); |
136 |
129 |
137 // The first letter of each day. |
130 // The first letter of each day. |
138 $this->weekday_initial[ __( 'Sunday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'S', 'Sunday initial' ); |
131 $this->weekday_initial[ __( 'Sunday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'S', 'Sunday initial' ); |
139 $this->weekday_initial[ __( 'Monday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'M', 'Monday initial' ); |
132 $this->weekday_initial[ __( 'Monday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'M', 'Monday initial' ); |
140 $this->weekday_initial[ __( 'Tuesday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'T', 'Tuesday initial' ); |
133 $this->weekday_initial[ __( 'Tuesday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'T', 'Tuesday initial' ); |
142 $this->weekday_initial[ __( 'Thursday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'T', 'Thursday initial' ); |
135 $this->weekday_initial[ __( 'Thursday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'T', 'Thursday initial' ); |
143 $this->weekday_initial[ __( 'Friday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'F', 'Friday initial' ); |
136 $this->weekday_initial[ __( 'Friday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'F', 'Friday initial' ); |
144 $this->weekday_initial[ __( 'Saturday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'S', 'Saturday initial' ); |
137 $this->weekday_initial[ __( 'Saturday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'S', 'Saturday initial' ); |
145 |
138 |
146 // Abbreviations for each day. |
139 // Abbreviations for each day. |
147 $this->weekday_abbrev[__('Sunday')] = /* translators: three-letter abbreviation of the weekday */ __('Sun'); |
140 $this->weekday_abbrev[ __( 'Sunday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Sun' ); |
148 $this->weekday_abbrev[__('Monday')] = /* translators: three-letter abbreviation of the weekday */ __('Mon'); |
141 $this->weekday_abbrev[ __( 'Monday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Mon' ); |
149 $this->weekday_abbrev[__('Tuesday')] = /* translators: three-letter abbreviation of the weekday */ __('Tue'); |
142 $this->weekday_abbrev[ __( 'Tuesday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Tue' ); |
150 $this->weekday_abbrev[__('Wednesday')] = /* translators: three-letter abbreviation of the weekday */ __('Wed'); |
143 $this->weekday_abbrev[ __( 'Wednesday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Wed' ); |
151 $this->weekday_abbrev[__('Thursday')] = /* translators: three-letter abbreviation of the weekday */ __('Thu'); |
144 $this->weekday_abbrev[ __( 'Thursday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Thu' ); |
152 $this->weekday_abbrev[__('Friday')] = /* translators: three-letter abbreviation of the weekday */ __('Fri'); |
145 $this->weekday_abbrev[ __( 'Friday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Fri' ); |
153 $this->weekday_abbrev[__('Saturday')] = /* translators: three-letter abbreviation of the weekday */ __('Sat'); |
146 $this->weekday_abbrev[ __( 'Saturday' ) ] = /* translators: three-letter abbreviation of the weekday */ __( 'Sat' ); |
154 |
147 |
155 // The Months |
148 // The Months |
156 $this->month['01'] = /* translators: month name */ __( 'January' ); |
149 $this->month['01'] = /* translators: month name */ __( 'January' ); |
157 $this->month['02'] = /* translators: month name */ __( 'February' ); |
150 $this->month['02'] = /* translators: month name */ __( 'February' ); |
158 $this->month['03'] = /* translators: month name */ __( 'March' ); |
151 $this->month['03'] = /* translators: month name */ __( 'March' ); |
193 $this->month_abbrev[ __( 'October' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Oct', 'October abbreviation' ); |
186 $this->month_abbrev[ __( 'October' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Oct', 'October abbreviation' ); |
194 $this->month_abbrev[ __( 'November' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Nov', 'November abbreviation' ); |
187 $this->month_abbrev[ __( 'November' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Nov', 'November abbreviation' ); |
195 $this->month_abbrev[ __( 'December' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Dec', 'December abbreviation' ); |
188 $this->month_abbrev[ __( 'December' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Dec', 'December abbreviation' ); |
196 |
189 |
197 // The Meridiems |
190 // The Meridiems |
198 $this->meridiem['am'] = __('am'); |
191 $this->meridiem['am'] = __( 'am' ); |
199 $this->meridiem['pm'] = __('pm'); |
192 $this->meridiem['pm'] = __( 'pm' ); |
200 $this->meridiem['AM'] = __('AM'); |
193 $this->meridiem['AM'] = __( 'AM' ); |
201 $this->meridiem['PM'] = __('PM'); |
194 $this->meridiem['PM'] = __( 'PM' ); |
202 |
195 |
203 // Numbers formatting |
196 // Numbers formatting |
204 // See https://secure.php.net/number_format |
197 // See https://secure.php.net/number_format |
205 |
198 |
206 /* translators: $thousands_sep argument for https://secure.php.net/number_format, default is , */ |
199 /* translators: $thousands_sep argument for https://secure.php.net/number_format, default is , */ |
220 $decimal_point = __( 'number_format_decimal_point' ); |
213 $decimal_point = __( 'number_format_decimal_point' ); |
221 |
214 |
222 $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point; |
215 $this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point; |
223 |
216 |
224 // Set text direction. |
217 // Set text direction. |
225 if ( isset( $GLOBALS['text_direction'] ) ) |
218 if ( isset( $GLOBALS['text_direction'] ) ) { |
226 $this->text_direction = $GLOBALS['text_direction']; |
219 $this->text_direction = $GLOBALS['text_direction']; |
227 /* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */ |
220 |
228 elseif ( 'rtl' == _x( 'ltr', 'text direction' ) ) |
221 /* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */ |
|
222 } elseif ( 'rtl' == _x( 'ltr', 'text direction' ) ) { |
229 $this->text_direction = 'rtl'; |
223 $this->text_direction = 'rtl'; |
230 |
224 } |
231 if ( 'rtl' === $this->text_direction && strpos( get_bloginfo( 'version' ), '-src' ) ) { |
225 |
|
226 if ( 'rtl' === $this->text_direction && strpos( $GLOBALS['wp_version'], '-src' ) ) { |
232 $this->text_direction = 'ltr'; |
227 $this->text_direction = 'ltr'; |
233 add_action( 'all_admin_notices', array( $this, 'rtl_src_admin_notice' ) ); |
228 add_action( 'all_admin_notices', array( $this, 'rtl_src_admin_notice' ) ); |
234 } |
229 } |
235 } |
230 } |
236 |
231 |
251 * by using 0 (zero). So the week starts with 0 (zero) |
246 * by using 0 (zero). So the week starts with 0 (zero) |
252 * and ends on Saturday with is fetched by using 6 (six). |
247 * and ends on Saturday with is fetched by using 6 (six). |
253 * |
248 * |
254 * @since 2.1.0 |
249 * @since 2.1.0 |
255 * |
250 * |
256 * @param int $weekday_number 0 for Sunday through 6 Saturday |
251 * @param int $weekday_number 0 for Sunday through 6 Saturday. |
257 * @return string Full translated weekday |
252 * @return string Full translated weekday. |
258 */ |
253 */ |
259 public function get_weekday($weekday_number) { |
254 public function get_weekday( $weekday_number ) { |
260 return $this->weekday[$weekday_number]; |
255 return $this->weekday[ $weekday_number ]; |
261 } |
256 } |
262 |
257 |
263 /** |
258 /** |
264 * Retrieve the translated weekday initial. |
259 * Retrieve the translated weekday initial. |
265 * |
260 * |
268 * pay attention to make sure that the starting letter does |
263 * pay attention to make sure that the starting letter does |
269 * not conflict. |
264 * not conflict. |
270 * |
265 * |
271 * @since 2.1.0 |
266 * @since 2.1.0 |
272 * |
267 * |
273 * @param string $weekday_name |
268 * @param string $weekday_name Full translated weekday word. |
274 * @return string |
269 * @return string Translated weekday initial. |
275 */ |
270 */ |
276 public function get_weekday_initial($weekday_name) { |
271 public function get_weekday_initial( $weekday_name ) { |
277 return $this->weekday_initial[$weekday_name]; |
272 return $this->weekday_initial[ $weekday_name ]; |
278 } |
273 } |
279 |
274 |
280 /** |
275 /** |
281 * Retrieve the translated weekday abbreviation. |
276 * Retrieve the translated weekday abbreviation. |
282 * |
277 * |
283 * The weekday abbreviation is retrieved by the translated |
278 * The weekday abbreviation is retrieved by the translated |
284 * full weekday word. |
279 * full weekday word. |
285 * |
280 * |
286 * @since 2.1.0 |
281 * @since 2.1.0 |
287 * |
282 * |
288 * @param string $weekday_name Full translated weekday word |
283 * @param string $weekday_name Full translated weekday word. |
289 * @return string Translated weekday abbreviation |
284 * @return string Translated weekday abbreviation. |
290 */ |
285 */ |
291 public function get_weekday_abbrev($weekday_name) { |
286 public function get_weekday_abbrev( $weekday_name ) { |
292 return $this->weekday_abbrev[$weekday_name]; |
287 return $this->weekday_abbrev[ $weekday_name ]; |
293 } |
288 } |
294 |
289 |
295 /** |
290 /** |
296 * Retrieve the full translated month by month number. |
291 * Retrieve the full translated month by month number. |
297 * |
292 * |
303 * You can use an integer instead and it will add the |
298 * You can use an integer instead and it will add the |
304 * '0' before the numbers less than 10 for you. |
299 * '0' before the numbers less than 10 for you. |
305 * |
300 * |
306 * @since 2.1.0 |
301 * @since 2.1.0 |
307 * |
302 * |
308 * @param string|int $month_number '01' through '12' |
303 * @param string|int $month_number '01' through '12'. |
309 * @return string Translated full month name |
304 * @return string Translated full month name. |
310 */ |
305 */ |
311 public function get_month($month_number) { |
306 public function get_month( $month_number ) { |
312 return $this->month[zeroise($month_number, 2)]; |
307 return $this->month[ zeroise( $month_number, 2 ) ]; |
313 } |
308 } |
314 |
309 |
315 /** |
310 /** |
316 * Retrieve translated version of month abbreviation string. |
311 * Retrieve translated version of month abbreviation string. |
317 * |
312 * |
318 * The $month_name parameter is expected to be the translated or |
313 * The $month_name parameter is expected to be the translated or |
319 * translatable version of the month. |
314 * translatable version of the month. |
320 * |
315 * |
321 * @since 2.1.0 |
316 * @since 2.1.0 |
322 * |
317 * |
323 * @param string $month_name Translated month to get abbreviated version |
318 * @param string $month_name Translated month to get abbreviated version. |
324 * @return string Translated abbreviated month |
319 * @return string Translated abbreviated month. |
325 */ |
320 */ |
326 public function get_month_abbrev($month_name) { |
321 public function get_month_abbrev( $month_name ) { |
327 return $this->month_abbrev[$month_name]; |
322 return $this->month_abbrev[ $month_name ]; |
328 } |
323 } |
329 |
324 |
330 /** |
325 /** |
331 * Retrieve translated version of meridiem string. |
326 * Retrieve translated version of meridiem string. |
332 * |
327 * |
335 * @since 2.1.0 |
330 * @since 2.1.0 |
336 * |
331 * |
337 * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version. |
332 * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version. |
338 * @return string Translated version |
333 * @return string Translated version |
339 */ |
334 */ |
340 public function get_meridiem($meridiem) { |
335 public function get_meridiem( $meridiem ) { |
341 return $this->meridiem[$meridiem]; |
336 return $this->meridiem[ $meridiem ]; |
342 } |
337 } |
343 |
338 |
344 /** |
339 /** |
345 * Global variables are deprecated. |
340 * Global variables are deprecated. |
346 * |
341 * |