Make WordPress Core


Ignore:
Timestamp:
04/02/2006 12:20:11 AM (19 years ago)
Author:
ryan
Message:

WP_Locale. Props Sewar. fixes #2568

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/locale.php

    r2232 r3676  
    11<?php
     2
    23// Date and Time
    34
    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');
     5class WP_Locale {
     6    var $weekday;
     7    var $weekday_initial;
     8    var $weekday_abbrev;
    129
    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;
    2312
    24 foreach ($weekday_initial as $weekday_ => $weekday_initial_) {
    25   $weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
    26 }
     13    var $meridiem;
    2714
    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');
    3624
    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');
    5034
    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        }
    6538
    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 Meridiems
     82        $this->meridiem['am'] = __('am');
     83        $this->meridiem['pm'] = __('pm');
     84        $this->meridiem['AM'] = __('AM');
     85        $this->meridiem['PM'] = __('PM');
     86    }
     87
     88    function get_weekday($weekday_number) {
     89        return $this->weekday[$weekday_number];
     90    }
     91
     92    function get_weekday_initial($weekday_name) {
     93        return $this->weekday_initial[$weekday_name];
     94    }
     95
     96    function get_weekday_abbrev($weekday_name) {
     97        return $this->weekday_abbrev[$weekday_name];
     98    }
     99
     100    function get_month($month_number) {
     101        return $this->month[zeroise($month_number, 2)];
     102    }
     103
     104    function get_month_initial($month_name) {
     105        return $this->month_initial[$month_name];
     106    }
     107
     108    function get_month_abbrev($month_name) {
     109        return $this->month_abbrev[$month_name];
     110    }
     111
     112    function get_meridiem($meridiem) {
     113        return $this->meridiem[$meridiem];
     114    }
     115
     116    // Global variables are deprecated. For backwards compatibility only.
     117    function register_globals() {
     118        $GLOBALS['weekday']         = $this->weekday;
     119        $GLOBALS['weekday_initial'] = $this->weekday_initial;
     120        $GLOBALS['weekday_abbrev']  = $this->weekday_abbrev;
     121        $GLOBALS['month']           = $this->month;
     122        $GLOBALS['month_abbrev']    = $this->month_abbrev;
     123    }
     124
     125    function WP_Locale() {
     126        $this->init();
     127        $this->register_globals();
     128    }
    68129}
    69130
Note: See TracChangeset for help on using the changeset viewer.