1 | <?php |
||
14 | class WP_Locale { |
||
15 | /** |
||
16 | * Stores the translated strings for the full weekday names. |
||
17 | * |
||
18 | * @since 2.1.0 |
||
19 | * @var array |
||
20 | */ |
||
21 | public $weekday; |
||
22 | |||
23 | /** |
||
24 | * Stores the translated strings for the one character weekday names. |
||
25 | * |
||
26 | * There is a hack to make sure that Tuesday and Thursday, as well |
||
27 | * as Sunday and Saturday, don't conflict. See init() method for more. |
||
28 | * |
||
29 | * @see WP_Locale::init() for how to handle the hack. |
||
30 | * |
||
31 | * @since 2.1.0 |
||
32 | * @var array |
||
33 | */ |
||
34 | public $weekday_initial; |
||
35 | |||
36 | /** |
||
37 | * Stores the translated strings for the abbreviated weekday names. |
||
38 | * |
||
39 | * @since 2.1.0 |
||
40 | * @var array |
||
41 | */ |
||
42 | public $weekday_abbrev; |
||
43 | |||
44 | /** |
||
45 | * Stores the default start of the week. |
||
46 | * |
||
47 | * @since 4.4.0 |
||
48 | * @var string |
||
49 | */ |
||
50 | public $start_of_week; |
||
51 | |||
52 | /** |
||
53 | * Stores the translated strings for the full month names. |
||
54 | * |
||
55 | * @since 2.1.0 |
||
56 | * @var array |
||
57 | */ |
||
58 | public $month; |
||
59 | |||
60 | /** |
||
61 | * Stores the translated strings for the abbreviated month names. |
||
62 | * |
||
63 | * @since 2.1.0 |
||
64 | * @var array |
||
65 | */ |
||
66 | public $month_abbrev; |
||
67 | |||
68 | /** |
||
69 | * Stores the translated strings for 'am' and 'pm'. |
||
70 | * |
||
71 | * Also the capitalized versions. |
||
72 | * |
||
73 | * @since 2.1.0 |
||
74 | * @var array |
||
75 | */ |
||
76 | public $meridiem; |
||
77 | |||
78 | /** |
||
79 | * The text direction of the locale language. |
||
80 | * |
||
81 | * Default is left to right 'ltr'. |
||
82 | * |
||
83 | * @since 2.1.0 |
||
84 | * @var string |
||
85 | */ |
||
86 | public $text_direction = 'ltr'; |
||
87 | |||
88 | /** |
||
89 | * The thousands separator and decimal point values used for localizing numbers. |
||
90 | * |
||
91 | * @since 2.3.0 |
||
92 | * @access public |
||
93 | * @var array |
||
94 | */ |
||
95 | public $number_format; |
||
96 | |||
97 | /** |
||
98 | * Sets up the translated strings and object properties. |
||
99 | * |
||
100 | * The method creates the translatable strings for various |
||
101 | * calendar elements. Which allows for specifying locale |
||
102 | * specific calendar names and text direction. |
||
103 | * |
||
104 | * @since 2.1.0 |
||
105 | * @access private |
||
106 | * |
||
107 | * @global string $text_direction |
||
108 | * @global string $wp_version |
||
109 | */ |
||
110 | public function init() { |
||
219 | |||
220 | /** |
||
221 | * Outputs an admin notice if the /build directory must be used for RTL. |
||
222 | * |
||
223 | * @since 3.8.0 |
||
224 | * @access public |
||
225 | */ |
||
226 | public function rtl_src_admin_notice() { |
||
230 | |||
231 | /** |
||
232 | * Retrieve the full translated weekday word. |
||
233 | * |
||
234 | * Week starts on translated Sunday and can be fetched |
||
235 | * by using 0 (zero). So the week starts with 0 (zero) |
||
236 | * and ends on Saturday with is fetched by using 6 (six). |
||
237 | * |
||
238 | * @since 2.1.0 |
||
239 | * @access public |
||
240 | * |
||
241 | * @param int $weekday_number 0 for Sunday through 6 Saturday |
||
242 | * @return string Full translated weekday |
||
243 | */ |
||
244 | public function get_weekday($weekday_number) { |
||
247 | |||
248 | /** |
||
249 | * Retrieve the translated weekday initial. |
||
250 | * |
||
251 | * The weekday initial is retrieved by the translated |
||
252 | * full weekday word. When translating the weekday initial |
||
253 | * pay attention to make sure that the starting letter does |
||
254 | * not conflict. |
||
255 | * |
||
256 | * @since 2.1.0 |
||
257 | * @access public |
||
258 | * |
||
259 | * @param string $weekday_name |
||
260 | * @return string |
||
261 | */ |
||
262 | public function get_weekday_initial($weekday_name) { |
||
265 | |||
266 | /** |
||
267 | * Retrieve the translated weekday abbreviation. |
||
268 | * |
||
269 | * The weekday abbreviation is retrieved by the translated |
||
270 | * full weekday word. |
||
271 | * |
||
272 | * @since 2.1.0 |
||
273 | * @access public |
||
274 | * |
||
275 | * @param string $weekday_name Full translated weekday word |
||
276 | * @return string Translated weekday abbreviation |
||
277 | */ |
||
278 | public function get_weekday_abbrev($weekday_name) { |
||
281 | |||
282 | /** |
||
283 | * Retrieve the full translated month by month number. |
||
284 | * |
||
285 | * The $month_number parameter has to be a string |
||
286 | * because it must have the '0' in front of any number |
||
287 | * that is less than 10. Starts from '01' and ends at |
||
288 | * '12'. |
||
289 | * |
||
290 | * You can use an integer instead and it will add the |
||
291 | * '0' before the numbers less than 10 for you. |
||
292 | * |
||
293 | * @since 2.1.0 |
||
294 | * @access public |
||
295 | * |
||
296 | * @param string|int $month_number '01' through '12' |
||
297 | * @return string Translated full month name |
||
298 | */ |
||
299 | public function get_month($month_number) { |
||
302 | |||
303 | /** |
||
304 | * Retrieve translated version of month abbreviation string. |
||
305 | * |
||
306 | * The $month_name parameter is expected to be the translated or |
||
307 | * translatable version of the month. |
||
308 | * |
||
309 | * @since 2.1.0 |
||
310 | * @access public |
||
311 | * |
||
312 | * @param string $month_name Translated month to get abbreviated version |
||
313 | * @return string Translated abbreviated month |
||
314 | */ |
||
315 | public function get_month_abbrev($month_name) { |
||
318 | |||
319 | /** |
||
320 | * Retrieve translated version of meridiem string. |
||
321 | * |
||
322 | * The $meridiem parameter is expected to not be translated. |
||
323 | * |
||
324 | * @since 2.1.0 |
||
325 | * @access public |
||
326 | * |
||
327 | * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version. |
||
328 | * @return string Translated version |
||
329 | */ |
||
330 | public function get_meridiem($meridiem) { |
||
333 | |||
334 | /** |
||
335 | * Global variables are deprecated. For backwards compatibility only. |
||
336 | * |
||
337 | * @deprecated For backwards compatibility only. |
||
338 | * @access private |
||
339 | * |
||
340 | * @global array $weekday |
||
341 | * @global array $weekday_initial |
||
342 | * @global array $weekday_abbrev |
||
343 | * @global array $month |
||
344 | * @global array $month_abbrev |
||
345 | * |
||
346 | * @since 2.1.0 |
||
347 | */ |
||
348 | public function register_globals() { |
||
355 | |||
356 | /** |
||
357 | * Constructor which calls helper methods to set up object variables |
||
358 | * |
||
359 | * @since 2.1.0 |
||
360 | */ |
||
361 | public function __construct() { |
||
365 | |||
366 | /** |
||
367 | * Checks if current locale is RTL. |
||
368 | * |
||
369 | * @since 3.0.0 |
||
370 | * @return bool Whether locale is RTL. |
||
371 | */ |
||
372 | public function is_rtl() { |
||
375 | |||
376 | /** |
||
377 | * Register date/time format strings for general POT. |
||
378 | * |
||
379 | * Private, unused method to add some date/time formats translated |
||
380 | * on wp-admin/options-general.php to the general POT that would |
||
381 | * otherwise be added to the admin POT. |
||
382 | * |
||
383 | * @since 3.6.0 |
||
384 | */ |
||
385 | public function _strings_for_pot() { |
||
393 | } |
||
394 | |||
408 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: