raw
mp-wp_genesis           1 <?php

mp-wp_genesis 2 /**
mp-wp_genesis 3 * Date and Time Locale object
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage i18n
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /**
mp-wp_genesis 10 * Class that loads the calendar locale.
mp-wp_genesis 11 *
mp-wp_genesis 12 * @since 2.1.0
mp-wp_genesis 13 */
mp-wp_genesis 14 class WP_Locale {
mp-wp_genesis 15 /**
mp-wp_genesis 16 * Stores the translated strings for the full weekday names.
mp-wp_genesis 17 *
mp-wp_genesis 18 * @since 2.1.0
mp-wp_genesis 19 * @var array
mp-wp_genesis 20 * @access private
mp-wp_genesis 21 */
mp-wp_genesis 22 var $weekday;
mp-wp_genesis 23
mp-wp_genesis 24 /**
mp-wp_genesis 25 * Stores the translated strings for the one character weekday names.
mp-wp_genesis 26 *
mp-wp_genesis 27 * There is a hack to make sure that Marti and Joi, as well
mp-wp_genesis 28 * as Duminica and Sambata don't conflict. See init() method for more.
mp-wp_genesis 29 *
mp-wp_genesis 30 * @see WP_Locale::init() for how to handle the hack.
mp-wp_genesis 31 *
mp-wp_genesis 32 * @since 2.1.0
mp-wp_genesis 33 * @var array
mp-wp_genesis 34 * @access private
mp-wp_genesis 35 */
mp-wp_genesis 36 var $weekday_initial;
mp-wp_genesis 37
mp-wp_genesis 38 /**
mp-wp_genesis 39 * Stores the translated strings for the abbreviated weekday names.
mp-wp_genesis 40 *
mp-wp_genesis 41 * @since 2.1.0
mp-wp_genesis 42 * @var array
mp-wp_genesis 43 * @access private
mp-wp_genesis 44 */
mp-wp_genesis 45 var $weekday_abbrev;
mp-wp_genesis 46
mp-wp_genesis 47 /**
mp-wp_genesis 48 * Stores the translated strings for the full month names.
mp-wp_genesis 49 *
mp-wp_genesis 50 * @since 2.1.0
mp-wp_genesis 51 * @var array
mp-wp_genesis 52 * @access private
mp-wp_genesis 53 */
mp-wp_genesis 54 var $month;
mp-wp_genesis 55
mp-wp_genesis 56 /**
mp-wp_genesis 57 * Stores the translated strings for the abbreviated month names.
mp-wp_genesis 58 *
mp-wp_genesis 59 * @since 2.1.0
mp-wp_genesis 60 * @var array
mp-wp_genesis 61 * @access private
mp-wp_genesis 62 */
mp-wp_genesis 63 var $month_abbrev;
mp-wp_genesis 64
mp-wp_genesis 65 /**
mp-wp_genesis 66 * Stores the translated strings for 'am' and 'pm'.
mp-wp_genesis 67 *
mp-wp_genesis 68 * Also the capalized versions.
mp-wp_genesis 69 *
mp-wp_genesis 70 * @since 2.1.0
mp-wp_genesis 71 * @var array
mp-wp_genesis 72 * @access private
mp-wp_genesis 73 */
mp-wp_genesis 74 var $meridiem;
mp-wp_genesis 75
mp-wp_genesis 76 /**
mp-wp_genesis 77 * The text direction of the locale language.
mp-wp_genesis 78 *
mp-wp_genesis 79 * Default is left to right 'ltr'.
mp-wp_genesis 80 *
mp-wp_genesis 81 * @since 2.1.0
mp-wp_genesis 82 * @var string
mp-wp_genesis 83 * @access private
mp-wp_genesis 84 */
mp-wp_genesis 85 var $text_direction = 'ltr';
mp-wp_genesis 86
mp-wp_genesis 87 /**
mp-wp_genesis 88 * Imports the global version to the class property.
mp-wp_genesis 89 *
mp-wp_genesis 90 * @since 2.1.0
mp-wp_genesis 91 * @var array
mp-wp_genesis 92 * @access private
mp-wp_genesis 93 */
mp-wp_genesis 94 var $locale_vars = array('text_direction');
mp-wp_genesis 95
mp-wp_genesis 96 /**
mp-wp_genesis 97 * Sets up the translated strings and object properties.
mp-wp_genesis 98 *
mp-wp_genesis 99 * The method creates the translatable strings for various
mp-wp_genesis 100 * calendar elements. Which allows for specifying locale
mp-wp_genesis 101 * specific calendar names and text direction.
mp-wp_genesis 102 *
mp-wp_genesis 103 * @since 2.1.0
mp-wp_genesis 104 * @access private
mp-wp_genesis 105 */
mp-wp_genesis 106 function init() {
mp-wp_genesis 107 // The Weekdays
mp-wp_genesis 108 $this->weekday[0] = __('Sunday');
mp-wp_genesis 109 $this->weekday[1] = __('Monday');
mp-wp_genesis 110 $this->weekday[2] = __('Tuesday');
mp-wp_genesis 111 $this->weekday[3] = __('Wednesday');
mp-wp_genesis 112 $this->weekday[4] = __('Thursday');
mp-wp_genesis 113 $this->weekday[5] = __('Friday');
mp-wp_genesis 114 $this->weekday[6] = __('Saturday');
mp-wp_genesis 115
mp-wp_genesis 116 // The first letter of each day. The _%day%_initial suffix is a hack to make
mp-wp_genesis 117 // sure the day initials are unique.
mp-wp_genesis 118 $this->weekday_initial[__('Sunday')] = __('S_Sunday_initial');
mp-wp_genesis 119 $this->weekday_initial[__('Monday')] = __('M_Monday_initial');
mp-wp_genesis 120 $this->weekday_initial[__('Tuesday')] = __('T_Tuesday_initial');
mp-wp_genesis 121 $this->weekday_initial[__('Wednesday')] = __('W_Wednesday_initial');
mp-wp_genesis 122 $this->weekday_initial[__('Thursday')] = __('T_Thursday_initial');
mp-wp_genesis 123 $this->weekday_initial[__('Friday')] = __('F_Friday_initial');
mp-wp_genesis 124 $this->weekday_initial[__('Saturday')] = __('S_Saturday_initial');
mp-wp_genesis 125
mp-wp_genesis 126 foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
mp-wp_genesis 127 $this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
mp-wp_genesis 128 }
mp-wp_genesis 129
mp-wp_genesis 130 // Abbreviations for each day.
mp-wp_genesis 131 $this->weekday_abbrev[__('Sunday')] = __('Sun');
mp-wp_genesis 132 $this->weekday_abbrev[__('Monday')] = __('Mon');
mp-wp_genesis 133 $this->weekday_abbrev[__('Tuesday')] = __('Tue');
mp-wp_genesis 134 $this->weekday_abbrev[__('Wednesday')] = __('Wed');
mp-wp_genesis 135 $this->weekday_abbrev[__('Thursday')] = __('Thu');
mp-wp_genesis 136 $this->weekday_abbrev[__('Friday')] = __('Fri');
mp-wp_genesis 137 $this->weekday_abbrev[__('Saturday')] = __('Sat');
mp-wp_genesis 138
mp-wp_genesis 139 // The Months
mp-wp_genesis 140 $this->month['01'] = __('January');
mp-wp_genesis 141 $this->month['02'] = __('February');
mp-wp_genesis 142 $this->month['03'] = __('March');
mp-wp_genesis 143 $this->month['04'] = __('April');
mp-wp_genesis 144 $this->month['05'] = __('May');
mp-wp_genesis 145 $this->month['06'] = __('June');
mp-wp_genesis 146 $this->month['07'] = __('July');
mp-wp_genesis 147 $this->month['08'] = __('August');
mp-wp_genesis 148 $this->month['09'] = __('September');
mp-wp_genesis 149 $this->month['10'] = __('October');
mp-wp_genesis 150 $this->month['11'] = __('November');
mp-wp_genesis 151 $this->month['12'] = __('December');
mp-wp_genesis 152
mp-wp_genesis 153 // Abbreviations for each month. Uses the same hack as above to get around the
mp-wp_genesis 154 // 'May' duplication.
mp-wp_genesis 155 $this->month_abbrev[__('January')] = __('Jan_January_abbreviation');
mp-wp_genesis 156 $this->month_abbrev[__('February')] = __('Feb_February_abbreviation');
mp-wp_genesis 157 $this->month_abbrev[__('March')] = __('Mar_March_abbreviation');
mp-wp_genesis 158 $this->month_abbrev[__('April')] = __('Apr_April_abbreviation');
mp-wp_genesis 159 $this->month_abbrev[__('May')] = __('May_May_abbreviation');
mp-wp_genesis 160 $this->month_abbrev[__('June')] = __('Jun_June_abbreviation');
mp-wp_genesis 161 $this->month_abbrev[__('July')] = __('Jul_July_abbreviation');
mp-wp_genesis 162 $this->month_abbrev[__('August')] = __('Aug_August_abbreviation');
mp-wp_genesis 163 $this->month_abbrev[__('September')] = __('Sep_September_abbreviation');
mp-wp_genesis 164 $this->month_abbrev[__('October')] = __('Oct_October_abbreviation');
mp-wp_genesis 165 $this->month_abbrev[__('November')] = __('Nov_November_abbreviation');
mp-wp_genesis 166 $this->month_abbrev[__('December')] = __('Dec_December_abbreviation');
mp-wp_genesis 167
mp-wp_genesis 168 foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
mp-wp_genesis 169 $this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
mp-wp_genesis 170 }
mp-wp_genesis 171
mp-wp_genesis 172 // The Meridiems
mp-wp_genesis 173 $this->meridiem['am'] = __(' a.m.');
mp-wp_genesis 174 $this->meridiem['pm'] = __(' p.m.');
mp-wp_genesis 175 $this->meridiem['AM'] = __(' a.m');
mp-wp_genesis 176 $this->meridiem['PM'] = __(' p.m.');
mp-wp_genesis 177
mp-wp_genesis 178 // Numbers formatting
mp-wp_genesis 179 // See http://php.net/number_format
mp-wp_genesis 180
mp-wp_genesis 181 $trans = _c('number_format_decimals|$decimals argument for http://php.net/number_format, default is 0');
mp-wp_genesis 182 $this->number_format['decimals'] = ('number_format_decimals' == $trans) ? 0 : $trans;
mp-wp_genesis 183
mp-wp_genesis 184 $trans = _c('number_format_decimal_point|$dec_point argument for http://php.net/number_format, default is .');
mp-wp_genesis 185 $this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
mp-wp_genesis 186
mp-wp_genesis 187 $trans = _c('number_format_thousands_sep|$thousands_sep argument for http://php.net/number_format, default is ,');
mp-wp_genesis 188 $this->number_format['thousands_sep'] = ('number_format_thousands_sep' == $trans) ? ',' : $trans;
mp-wp_genesis 189
mp-wp_genesis 190 // Import global locale vars set during inclusion of $locale.php.
mp-wp_genesis 191 foreach ( (array) $this->locale_vars as $var ) {
mp-wp_genesis 192 if ( isset($GLOBALS[$var]) )
mp-wp_genesis 193 $this->$var = $GLOBALS[$var];
mp-wp_genesis 194 }
mp-wp_genesis 195
mp-wp_genesis 196 }
mp-wp_genesis 197
mp-wp_genesis 198 /**
mp-wp_genesis 199 * Retrieve the full translated weekday word.
mp-wp_genesis 200 *
mp-wp_genesis 201 * Week starts on translated Duminica and can be fetched
mp-wp_genesis 202 * by using 0 (zero). So the week starts with 0 (zero)
mp-wp_genesis 203 * and ends on Sambata with is fetched by using 6 (six).
mp-wp_genesis 204 *
mp-wp_genesis 205 * @since 2.1.0
mp-wp_genesis 206 * @access public
mp-wp_genesis 207 *
mp-wp_genesis 208 * @param int $weekday_number 0 for Duminica through 6 Sambata
mp-wp_genesis 209 * @return string Full translated weekday
mp-wp_genesis 210 */
mp-wp_genesis 211 function get_weekday($weekday_number) {
mp-wp_genesis 212 return $this->weekday[$weekday_number];
mp-wp_genesis 213 }
mp-wp_genesis 214
mp-wp_genesis 215 /**
mp-wp_genesis 216 * Retrieve the translated weekday initial.
mp-wp_genesis 217 *
mp-wp_genesis 218 * The weekday initial is retrieved by the translated
mp-wp_genesis 219 * full weekday word. When translating the weekday initial
mp-wp_genesis 220 * pay attention to make sure that the starting letter does
mp-wp_genesis 221 * not conflict.
mp-wp_genesis 222 *
mp-wp_genesis 223 * @since 2.1.0
mp-wp_genesis 224 * @access public
mp-wp_genesis 225 *
mp-wp_genesis 226 * @param string $weekday_name
mp-wp_genesis 227 * @return string
mp-wp_genesis 228 */
mp-wp_genesis 229 function get_weekday_initial($weekday_name) {
mp-wp_genesis 230 return $this->weekday_initial[$weekday_name];
mp-wp_genesis 231 }
mp-wp_genesis 232
mp-wp_genesis 233 /**
mp-wp_genesis 234 * Retrieve the translated weekday abbreviation.
mp-wp_genesis 235 *
mp-wp_genesis 236 * The weekday abbreviation is retrieved by the translated
mp-wp_genesis 237 * full weekday word.
mp-wp_genesis 238 *
mp-wp_genesis 239 * @since 2.1.0
mp-wp_genesis 240 * @access public
mp-wp_genesis 241 *
mp-wp_genesis 242 * @param string $weekday_name Full translated weekday word
mp-wp_genesis 243 * @return string Translated weekday abbreviation
mp-wp_genesis 244 */
mp-wp_genesis 245 function get_weekday_abbrev($weekday_name) {
mp-wp_genesis 246 return $this->weekday_abbrev[$weekday_name];
mp-wp_genesis 247 }
mp-wp_genesis 248
mp-wp_genesis 249 /**
mp-wp_genesis 250 * Retrieve the full translated month by month number.
mp-wp_genesis 251 *
mp-wp_genesis 252 * The $month_number parameter has to be a string
mp-wp_genesis 253 * because it must have the '0' in front of any number
mp-wp_genesis 254 * that is less than 10. Starts from '01' and ends at
mp-wp_genesis 255 * '12'.
mp-wp_genesis 256 *
mp-wp_genesis 257 * You can use an integer instead and it will add the
mp-wp_genesis 258 * '0' before the numbers less than 10 for you.
mp-wp_genesis 259 *
mp-wp_genesis 260 * @since 2.1.0
mp-wp_genesis 261 * @access public
mp-wp_genesis 262 *
mp-wp_genesis 263 * @param string|int $month_number '01' through '12'
mp-wp_genesis 264 * @return string Translated full month name
mp-wp_genesis 265 */
mp-wp_genesis 266 function get_month($month_number) {
mp-wp_genesis 267 return $this->month[zeroise($month_number, 2)];
mp-wp_genesis 268 }
mp-wp_genesis 269
mp-wp_genesis 270 /**
mp-wp_genesis 271 * Retrieve translated version of month abbreviation string.
mp-wp_genesis 272 *
mp-wp_genesis 273 * The $month_name parameter is expected to be the translated or
mp-wp_genesis 274 * translatable version of the month.
mp-wp_genesis 275 *
mp-wp_genesis 276 * @since 2.1.0
mp-wp_genesis 277 * @access public
mp-wp_genesis 278 *
mp-wp_genesis 279 * @param string $month_name Translated month to get abbreviated version
mp-wp_genesis 280 * @return string Translated abbreviated month
mp-wp_genesis 281 */
mp-wp_genesis 282 function get_month_abbrev($month_name) {
mp-wp_genesis 283 return $this->month_abbrev[$month_name];
mp-wp_genesis 284 }
mp-wp_genesis 285
mp-wp_genesis 286 /**
mp-wp_genesis 287 * Retrieve translated version of meridiem string.
mp-wp_genesis 288 *
mp-wp_genesis 289 * The $meridiem parameter is expected to not be translated.
mp-wp_genesis 290 *
mp-wp_genesis 291 * @since 2.1.0
mp-wp_genesis 292 * @access public
mp-wp_genesis 293 *
mp-wp_genesis 294 * @param string $meridiem Either 'am', 'pm', 'AM', or 'PM'. Not translated version.
mp-wp_genesis 295 * @return string Translated version
mp-wp_genesis 296 */
mp-wp_genesis 297 function get_meridiem($meridiem) {
mp-wp_genesis 298 return $this->meridiem[$meridiem];
mp-wp_genesis 299 }
mp-wp_genesis 300
mp-wp_genesis 301 /**
mp-wp_genesis 302 * Global variables are deprecated. For backwards compatibility only.
mp-wp_genesis 303 *
mp-wp_genesis 304 * @deprecated For backwards compatibility only.
mp-wp_genesis 305 * @access private
mp-wp_genesis 306 *
mp-wp_genesis 307 * @since 2.1.0
mp-wp_genesis 308 */
mp-wp_genesis 309 function register_globals() {
mp-wp_genesis 310 $GLOBALS['weekday'] = $this->weekday;
mp-wp_genesis 311 $GLOBALS['weekday_initial'] = $this->weekday_initial;
mp-wp_genesis 312 $GLOBALS['weekday_abbrev'] = $this->weekday_abbrev;
mp-wp_genesis 313 $GLOBALS['month'] = $this->month;
mp-wp_genesis 314 $GLOBALS['month_abbrev'] = $this->month_abbrev;
mp-wp_genesis 315 }
mp-wp_genesis 316
mp-wp_genesis 317 /**
mp-wp_genesis 318 * PHP4 style constructor which calls helper methods to set up object variables
mp-wp_genesis 319 *
mp-wp_genesis 320 * @uses WP_Locale::init()
mp-wp_genesis 321 * @uses WP_Locale::register_globals()
mp-wp_genesis 322 * @since 2.1.0
mp-wp_genesis 323 *
mp-wp_genesis 324 * @return WP_Locale
mp-wp_genesis 325 */
mp-wp_genesis 326 function WP_Locale() {
mp-wp_genesis 327 $this->init();
mp-wp_genesis 328 $this->register_globals();
mp-wp_genesis 329 }
mp-wp_genesis 330 }
mp-wp_genesis 331
mp-wp_genesis 332 ?>