yiiapi/framework/utils/CLocalizedFormatter.php

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
/**
 * CLocalizedFormatter class file.
 *
 * @author Carsten Brandt <mail@cebe.cc>
 * @link http://www.yiiframework.com/
 * @copyright 2008-2013 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

/**
 * CLocalizedFormatter provides a set of commonly used data formatting methods based on the current locale settings.
 *
 * It provides the same functionality as {@link CFormatter}, but overrides all the settings for
 * {@link booleanFormat}, {@link datetimeFormat} and {@link numberFormat} with the values for the
 * current locale. Because of this you are not able to configure these properties for CLocalizedFormatter directly.
 * Date and time format can be adjusted by setting {@link dateFormat} and {@link timeFormat}.
 *
 * It uses {@link CApplication::locale} by default but you can set a custom locale by using {@link setLocale}-method.
 *
 * For a list of recognizable format types, and details on how to call the formatter methods,
 * see {@link CFormatter} documentation.
 *
 * To replace the application component 'format', which is registered by {@link CApplication} by default, you can
 * put this in your application 'components' config:
 * <code>
 * 'format' => array(
 *     'class' => 'CLocalizedFormatter',
 * ),
 * </code>
 *
 * @author Carsten Brandt <mail@cebe.cc>
 * @package system.utils
 * @since 1.1.14
 */
class CLocalizedFormatter extends CFormatter
{
	private $_locale;
	/**
	 * @var string the width of the date pattern. It can be 'full', 'long', 'medium' and 'short'. Defaults to 'medium'.
	 * @see CDateFormatter::formatDateTime()
	 */
	public $dateFormat='medium';
	/**
	 * @var string the width of the time pattern. It can be 'full', 'long', 'medium' and 'short'. Defaults to 'medium'.
	 * @see CDateFormatter::formatDateTime()
	 */
	public $timeFormat='medium';

	/**
	 * Set the locale to use for formatting values.
	 * @param CLocale|string $locale an instance of CLocale or a locale ID
	 */
	public function setLocale($locale)
	{
		if(is_string($locale))
			$locale=CLocale::getInstance($locale);
		$this->sizeFormat['decimalSeparator']=$locale->getNumberSymbol('decimal');
		$this->_locale=$locale;
	}
后面还有 71 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。