wp/wp-includes/class-wp-locale.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   113 	 * specific calendar names and text direction.
   113 	 * specific calendar names and text direction.
   114 	 *
   114 	 *
   115 	 * @since 2.1.0
   115 	 * @since 2.1.0
   116 	 *
   116 	 *
   117 	 * @global string $text_direction
   117 	 * @global string $text_direction
   118 	 * @global string $wp_version
   118 	 * @global string $wp_version     The WordPress version string.
   119 	 */
   119 	 */
   120 	public function init() {
   120 	public function init() {
   121 		// The Weekdays
   121 		// The weekdays.
   122 		$this->weekday[0] = /* translators: weekday */ __( 'Sunday' );
   122 		$this->weekday[0] = /* translators: Weekday. */ __( 'Sunday' );
   123 		$this->weekday[1] = /* translators: weekday */ __( 'Monday' );
   123 		$this->weekday[1] = /* translators: Weekday. */ __( 'Monday' );
   124 		$this->weekday[2] = /* translators: weekday */ __( 'Tuesday' );
   124 		$this->weekday[2] = /* translators: Weekday. */ __( 'Tuesday' );
   125 		$this->weekday[3] = /* translators: weekday */ __( 'Wednesday' );
   125 		$this->weekday[3] = /* translators: Weekday. */ __( 'Wednesday' );
   126 		$this->weekday[4] = /* translators: weekday */ __( 'Thursday' );
   126 		$this->weekday[4] = /* translators: Weekday. */ __( 'Thursday' );
   127 		$this->weekday[5] = /* translators: weekday */ __( 'Friday' );
   127 		$this->weekday[5] = /* translators: Weekday. */ __( 'Friday' );
   128 		$this->weekday[6] = /* translators: weekday */ __( 'Saturday' );
   128 		$this->weekday[6] = /* translators: Weekday. */ __( 'Saturday' );
   129 
   129 
   130 		// The first letter of each day.
   130 		// The first letter of each day.
   131 		$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' );
   132 		$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' );
   133 		$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' );
   134 		$this->weekday_initial[ __( 'Wednesday' ) ] = /* translators: one-letter abbreviation of the weekday */ _x( 'W', 'Wednesday initial' );
   134 		$this->weekday_initial[ __( 'Wednesday' ) ] = /* translators: One-letter abbreviation of the weekday. */ _x( 'W', 'Wednesday initial' );
   135 		$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' );
   136 		$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' );
   137 		$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' );
   138 
   138 
   139 		// Abbreviations for each day.
   139 		// Abbreviations for each day.
   140 		$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' );
   141 		$this->weekday_abbrev[ __( 'Monday' ) ]    = /* translators: three-letter abbreviation of the weekday */ __( 'Mon' );
   141 		$this->weekday_abbrev[ __( 'Monday' ) ]    = /* translators: Ttree-letter abbreviation of the weekday. */ __( 'Mon' );
   142 		$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' );
   143 		$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' );
   144 		$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' );
   145 		$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' );
   146 		$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' );
   147 
   147 
   148 		// The Months
   148 		// The months.
   149 		$this->month['01'] = /* translators: month name */ __( 'January' );
   149 		$this->month['01'] = /* translators: Month name. */ __( 'January' );
   150 		$this->month['02'] = /* translators: month name */ __( 'February' );
   150 		$this->month['02'] = /* translators: Month name. */ __( 'February' );
   151 		$this->month['03'] = /* translators: month name */ __( 'March' );
   151 		$this->month['03'] = /* translators: Month name. */ __( 'March' );
   152 		$this->month['04'] = /* translators: month name */ __( 'April' );
   152 		$this->month['04'] = /* translators: Month name. */ __( 'April' );
   153 		$this->month['05'] = /* translators: month name */ __( 'May' );
   153 		$this->month['05'] = /* translators: Month name. */ __( 'May' );
   154 		$this->month['06'] = /* translators: month name */ __( 'June' );
   154 		$this->month['06'] = /* translators: Month name. */ __( 'June' );
   155 		$this->month['07'] = /* translators: month name */ __( 'July' );
   155 		$this->month['07'] = /* translators: Month name. */ __( 'July' );
   156 		$this->month['08'] = /* translators: month name */ __( 'August' );
   156 		$this->month['08'] = /* translators: Month name. */ __( 'August' );
   157 		$this->month['09'] = /* translators: month name */ __( 'September' );
   157 		$this->month['09'] = /* translators: Month name. */ __( 'September' );
   158 		$this->month['10'] = /* translators: month name */ __( 'October' );
   158 		$this->month['10'] = /* translators: Month name. */ __( 'October' );
   159 		$this->month['11'] = /* translators: month name */ __( 'November' );
   159 		$this->month['11'] = /* translators: Month name. */ __( 'November' );
   160 		$this->month['12'] = /* translators: month name */ __( 'December' );
   160 		$this->month['12'] = /* translators: Month name. */ __( 'December' );
   161 
   161 
   162 		// The Months, genitive
   162 		// The months, genitive.
   163 		$this->month_genitive['01'] = /* translators: month name, genitive */ _x( 'January', 'genitive' );
   163 		$this->month_genitive['01'] = /* translators: Month name, genitive. */ _x( 'January', 'genitive' );
   164 		$this->month_genitive['02'] = /* translators: month name, genitive */ _x( 'February', 'genitive' );
   164 		$this->month_genitive['02'] = /* translators: Month name, genitive. */ _x( 'February', 'genitive' );
   165 		$this->month_genitive['03'] = /* translators: month name, genitive */ _x( 'March', 'genitive' );
   165 		$this->month_genitive['03'] = /* translators: Month name, genitive. */ _x( 'March', 'genitive' );
   166 		$this->month_genitive['04'] = /* translators: month name, genitive */ _x( 'April', 'genitive' );
   166 		$this->month_genitive['04'] = /* translators: Month name, genitive. */ _x( 'April', 'genitive' );
   167 		$this->month_genitive['05'] = /* translators: month name, genitive */ _x( 'May', 'genitive' );
   167 		$this->month_genitive['05'] = /* translators: Month name, genitive. */ _x( 'May', 'genitive' );
   168 		$this->month_genitive['06'] = /* translators: month name, genitive */ _x( 'June', 'genitive' );
   168 		$this->month_genitive['06'] = /* translators: Month name, genitive. */ _x( 'June', 'genitive' );
   169 		$this->month_genitive['07'] = /* translators: month name, genitive */ _x( 'July', 'genitive' );
   169 		$this->month_genitive['07'] = /* translators: Month name, genitive. */ _x( 'July', 'genitive' );
   170 		$this->month_genitive['08'] = /* translators: month name, genitive */ _x( 'August', 'genitive' );
   170 		$this->month_genitive['08'] = /* translators: Month name, genitive. */ _x( 'August', 'genitive' );
   171 		$this->month_genitive['09'] = /* translators: month name, genitive */ _x( 'September', 'genitive' );
   171 		$this->month_genitive['09'] = /* translators: Month name, genitive. */ _x( 'September', 'genitive' );
   172 		$this->month_genitive['10'] = /* translators: month name, genitive */ _x( 'October', 'genitive' );
   172 		$this->month_genitive['10'] = /* translators: Month name, genitive. */ _x( 'October', 'genitive' );
   173 		$this->month_genitive['11'] = /* translators: month name, genitive */ _x( 'November', 'genitive' );
   173 		$this->month_genitive['11'] = /* translators: Month name, genitive. */ _x( 'November', 'genitive' );
   174 		$this->month_genitive['12'] = /* translators: month name, genitive */ _x( 'December', 'genitive' );
   174 		$this->month_genitive['12'] = /* translators: Month name, genitive. */ _x( 'December', 'genitive' );
   175 
   175 
   176 		// Abbreviations for each month.
   176 		// Abbreviations for each month.
   177 		$this->month_abbrev[ __( 'January' ) ]   = /* translators: three-letter abbreviation of the month */ _x( 'Jan', 'January abbreviation' );
   177 		$this->month_abbrev[ __( 'January' ) ]   = /* translators: Three-letter abbreviation of the month. */ _x( 'Jan', 'January abbreviation' );
   178 		$this->month_abbrev[ __( 'February' ) ]  = /* translators: three-letter abbreviation of the month */ _x( 'Feb', 'February abbreviation' );
   178 		$this->month_abbrev[ __( 'February' ) ]  = /* translators: Three-letter abbreviation of the month. */ _x( 'Feb', 'February abbreviation' );
   179 		$this->month_abbrev[ __( 'March' ) ]     = /* translators: three-letter abbreviation of the month */ _x( 'Mar', 'March abbreviation' );
   179 		$this->month_abbrev[ __( 'March' ) ]     = /* translators: Three-letter abbreviation of the month. */ _x( 'Mar', 'March abbreviation' );
   180 		$this->month_abbrev[ __( 'April' ) ]     = /* translators: three-letter abbreviation of the month */ _x( 'Apr', 'April abbreviation' );
   180 		$this->month_abbrev[ __( 'April' ) ]     = /* translators: Three-letter abbreviation of the month. */ _x( 'Apr', 'April abbreviation' );
   181 		$this->month_abbrev[ __( 'May' ) ]       = /* translators: three-letter abbreviation of the month */ _x( 'May', 'May abbreviation' );
   181 		$this->month_abbrev[ __( 'May' ) ]       = /* translators: Three-letter abbreviation of the month. */ _x( 'May', 'May abbreviation' );
   182 		$this->month_abbrev[ __( 'June' ) ]      = /* translators: three-letter abbreviation of the month */ _x( 'Jun', 'June abbreviation' );
   182 		$this->month_abbrev[ __( 'June' ) ]      = /* translators: Three-letter abbreviation of the month. */ _x( 'Jun', 'June abbreviation' );
   183 		$this->month_abbrev[ __( 'July' ) ]      = /* translators: three-letter abbreviation of the month */ _x( 'Jul', 'July abbreviation' );
   183 		$this->month_abbrev[ __( 'July' ) ]      = /* translators: Three-letter abbreviation of the month. */ _x( 'Jul', 'July abbreviation' );
   184 		$this->month_abbrev[ __( 'August' ) ]    = /* translators: three-letter abbreviation of the month */ _x( 'Aug', 'August abbreviation' );
   184 		$this->month_abbrev[ __( 'August' ) ]    = /* translators: Three-letter abbreviation of the month. */ _x( 'Aug', 'August abbreviation' );
   185 		$this->month_abbrev[ __( 'September' ) ] = /* translators: three-letter abbreviation of the month */ _x( 'Sep', 'September abbreviation' );
   185 		$this->month_abbrev[ __( 'September' ) ] = /* translators: Three-letter abbreviation of the month. */ _x( 'Sep', 'September abbreviation' );
   186 		$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' );
   187 		$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' );
   188 		$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' );
   189 
   189 
   190 		// The Meridiems
   190 		// The meridiems.
   191 		$this->meridiem['am'] = __( 'am' );
   191 		$this->meridiem['am'] = __( 'am' );
   192 		$this->meridiem['pm'] = __( 'pm' );
   192 		$this->meridiem['pm'] = __( 'pm' );
   193 		$this->meridiem['AM'] = __( 'AM' );
   193 		$this->meridiem['AM'] = __( 'AM' );
   194 		$this->meridiem['PM'] = __( 'PM' );
   194 		$this->meridiem['PM'] = __( 'PM' );
   195 
   195 
   196 		// Numbers formatting
   196 		// Numbers formatting.
   197 		// See https://secure.php.net/number_format
   197 		// See https://www.php.net/number_format
   198 
   198 
   199 		/* translators: $thousands_sep argument for https://secure.php.net/number_format, default is , */
   199 		/* translators: $thousands_sep argument for https://www.php.net/number_format, default is ',' */
   200 		$thousands_sep = __( 'number_format_thousands_sep' );
   200 		$thousands_sep = __( 'number_format_thousands_sep' );
   201 
   201 
   202 		if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
   202 		// Replace space with a non-breaking space to avoid wrapping.
   203 			// Replace space with a non-breaking space to avoid wrapping.
   203 		$thousands_sep = str_replace( ' ', ' ', $thousands_sep );
   204 			$thousands_sep = str_replace( ' ', ' ', $thousands_sep );
       
   205 		} else {
       
   206 			// PHP < 5.4.0 does not support multiple bytes in thousands separator.
       
   207 			$thousands_sep = str_replace( array( '&nbsp;', '&#160;' ), ' ', $thousands_sep );
       
   208 		}
       
   209 
   204 
   210 		$this->number_format['thousands_sep'] = ( 'number_format_thousands_sep' === $thousands_sep ) ? ',' : $thousands_sep;
   205 		$this->number_format['thousands_sep'] = ( 'number_format_thousands_sep' === $thousands_sep ) ? ',' : $thousands_sep;
   211 
   206 
   212 		/* translators: $dec_point argument for https://secure.php.net/number_format, default is . */
   207 		/* translators: $dec_point argument for https://www.php.net/number_format, default is '.' */
   213 		$decimal_point = __( 'number_format_decimal_point' );
   208 		$decimal_point = __( 'number_format_decimal_point' );
   214 
   209 
   215 		$this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point;
   210 		$this->number_format['decimal_point'] = ( 'number_format_decimal_point' === $decimal_point ) ? '.' : $decimal_point;
   216 
   211 
   217 		// Set text direction.
   212 		// Set text direction.
   218 		if ( isset( $GLOBALS['text_direction'] ) ) {
   213 		if ( isset( $GLOBALS['text_direction'] ) ) {
   219 			$this->text_direction = $GLOBALS['text_direction'];
   214 			$this->text_direction = $GLOBALS['text_direction'];
   220 
   215 
   221 			/* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */
   216 			/* translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. */
   222 		} elseif ( 'rtl' == _x( 'ltr', 'text direction' ) ) {
   217 		} elseif ( 'rtl' === _x( 'ltr', 'text direction' ) ) {
   223 			$this->text_direction = 'rtl';
   218 			$this->text_direction = 'rtl';
   224 		}
   219 		}
   225 
       
   226 		if ( 'rtl' === $this->text_direction && strpos( $GLOBALS['wp_version'], '-src' ) ) {
       
   227 			$this->text_direction = 'ltr';
       
   228 			add_action( 'all_admin_notices', array( $this, 'rtl_src_admin_notice' ) );
       
   229 		}
       
   230 	}
       
   231 
       
   232 	/**
       
   233 	 * Outputs an admin notice if the /build directory must be used for RTL.
       
   234 	 *
       
   235 	 * @since 3.8.0
       
   236 	 */
       
   237 	public function rtl_src_admin_notice() {
       
   238 		/* translators: %s: Name of the directory (build) */
       
   239 		echo '<div class="error"><p>' . sprintf( __( 'The %s directory of the develop repository must be used for RTL.' ), '<code>build</code>' ) . '</p></div>';
       
   240 	}
   220 	}
   241 
   221 
   242 	/**
   222 	/**
   243 	 * Retrieve the full translated weekday word.
   223 	 * Retrieve the full translated weekday word.
   244 	 *
   224 	 *
   364 	 *
   344 	 *
   365 	 * @since 3.0.0
   345 	 * @since 3.0.0
   366 	 * @return bool Whether locale is RTL.
   346 	 * @return bool Whether locale is RTL.
   367 	 */
   347 	 */
   368 	public function is_rtl() {
   348 	public function is_rtl() {
   369 		return 'rtl' == $this->text_direction;
   349 		return 'rtl' === $this->text_direction;
   370 	}
   350 	}
   371 
   351 
   372 	/**
   352 	/**
   373 	 * Register date/time format strings for general POT.
   353 	 * Register date/time format strings for general POT.
   374 	 *
   354 	 *
   377 	 * otherwise be added to the admin POT.
   357 	 * otherwise be added to the admin POT.
   378 	 *
   358 	 *
   379 	 * @since 3.6.0
   359 	 * @since 3.6.0
   380 	 */
   360 	 */
   381 	public function _strings_for_pot() {
   361 	public function _strings_for_pot() {
   382 		/* translators: localized date format, see https://secure.php.net/date */
   362 		/* translators: Localized date format, see https://www.php.net/date */
   383 		__( 'F j, Y' );
   363 		__( 'F j, Y' );
   384 		/* translators: localized time format, see https://secure.php.net/date */
   364 		/* translators: Localized time format, see https://www.php.net/date */
   385 		__( 'g:i a' );
   365 		__( 'g:i a' );
   386 		/* translators: localized date and time format, see https://secure.php.net/date */
   366 		/* translators: Localized date and time format, see https://www.php.net/date */
   387 		__( 'F j, Y g:i a' );
   367 		__( 'F j, Y g:i a' );
   388 	}
   368 	}
   389 }
   369 }