当前位置: 首页>>代码示例>>PHP>>正文


PHP CLocale::getInstance方法代码示例

本文整理汇总了PHP中CLocale::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP CLocale::getInstance方法的具体用法?PHP CLocale::getInstance怎么用?PHP CLocale::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLocale的用法示例。


在下文中一共展示了CLocale::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

	/**
	 * Constructor.
	 * @param mixed $locale locale ID (string) or CLocale instance
	 */
	public function __construct($locale)
	{
		if(is_string($locale))
			$this->_locale=CLocale::getInstance($locale);
		else
			$this->_locale=$locale;
	}
开发者ID:alsvader,项目名称:hackbanero,代码行数:11,代码来源:CNumberFormatter.php

示例2: getLocale

 /**
  * This function is here because we aren't creating a locale file for every client.
  * Thus we provide a fallback to "en".
  */
 public function getLocale($localeID = null)
 {
     try {
         return parent::getLocale($localeID);
     } catch (Exception $e) {
         return CLocale::getInstance('en');
     }
 }
开发者ID:a303,项目名称:smart_lp2,代码行数:12,代码来源:EWebApplication.php

示例3: setLocale

 /**
  * 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;
 }
开发者ID:ubertheme,项目名称:module-ubdatamigration,代码行数:12,代码来源:CLocalizedFormatter.php

示例4: getAvailableLanguages

 /**
  * Returns a key value map of the available languages, including the source 
  * language, where the key is the locale and the value is the display name
  * @return array
  */
 public static function getAvailableLanguages()
 {
     $locales = array('en');
     $translations = new FilesystemIterator(Yii::app()->basePath . '/messages');
     foreach ($translations as $fileInfo) {
         // Skip the .gitkeep file
         if ($fileInfo->isDir()) {
             $locales[] = $fileInfo->getFilename();
         }
     }
     $languages = array();
     foreach ($locales as $language) {
         $languages[$language] = CLocale::getInstance('en')->getLanguage($language);
     }
     return $languages;
 }
开发者ID:pweisenburger,项目名称:xbmc-video-server,代码行数:21,代码来源:LanguageManager.php

示例5: getLocale

 public function getLocale($localeID = null)
 {
     return CLocale::getInstance($localeID === null ? $this->getLanguage() : $localeID);
 }
开发者ID:smokeelow,项目名称:faicore,代码行数:4,代码来源:yiilite.php

示例6: array

if (!isset($this->breadcrumbs)) {
    $this->breadcrumbs = array('Grupocontactos' => array(Yii::t('app', 'index')), Yii::t('app', 'Manage'));
}
if (!isset($this->menu) || $this->menu === array()) {
    $this->menu = array(array('label' => Yii::t('app', 'List') . ' Grupocontacto', 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' Grupocontacto', 'url' => array('create')));
}
Yii::app()->clientScript->registerScript('search', "\n\t\t\t\$('.search-button').click(function(){\n\t\t\t\t\$('.search-form').toggle();\n\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\$('.search-form form').submit(function(){\n\t\t\t\t\$.fn.yiiGridView.update('grupocontacto-grid', {\ndata: \$(this).serialize()\n});\n\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t");
?>

<h1> <?php 
echo Yii::t('app', 'Manage');
?>
 Grupocontactos</h1>

<?php 
echo "<ul>";
foreach ($model->relations() as $key => $relation) {
    echo "<li>" . substr(str_replace("Relation", "", $relation[0]), 1) . " " . CHtml::link(Yii::t("app", $relation[1]), array($this->resolveRelationController($relation) . "/admin")) . " (" . $relation[2] . ")" . " </li>";
}
echo "</ul>";
echo CHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div>

<?php 
$locale = CLocale::getInstance(Yii::app()->language);
$this->widget('zii.widgets.grid.CGridView', array('id' => 'grupocontacto-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'contactoid', 'value' => 'CHtml::value($data,\'contacto.recordTitle\')', 'filter' => CHtml::listData(Contacto::model()->findAll(), 'contactoid', 'recordTitle')), array('name' => 'grupoid', 'value' => 'CHtml::value($data,\'grupo.nombre\')', 'filter' => CHtml::listData(Grupo::model()->findAll(), 'grupoid', 'nombre')), array('class' => 'CButtonColumn'))));
开发者ID:rusli-nasir,项目名称:smsempresayii,代码行数:31,代码来源:admin.php

示例7: testGetTerritory

 /**
  * @dataProvider providerGetTerritory
  */
 public function testGetTerritory($ctorLocale, $methodLocale, $assertion)
 {
     $locale = CLocale::getInstance($ctorLocale);
     $this->assertEquals($assertion, $locale->getTerritory($methodLocale));
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:8,代码来源:CLocaleTest.php

示例8: getLanguages

 /**
  * Returns the supported SourceBans languages
  * 
  * @return array the supported SourceBans languages
  */
 public function getLanguages()
 {
     static $_data = array();
     if (empty($_data)) {
         $basePath = Yii::app()->getMessages()->basePath;
         $folder = @opendir($basePath);
         while (($file = @readdir($folder)) !== false) {
             if ($file[0] === '.' || !is_dir($basePath . DIRECTORY_SEPARATOR . $file)) {
                 continue;
             }
             $_data[$file] = CLocale::getInstance($file)->getLocaleDisplayName($file);
             if ($file !== Yii::app()->language) {
                 $_data[$file] .= ' (' . Yii::app()->locale->getLocaleDisplayName($file) . ')';
             }
         }
         closedir($folder);
         asort($_data);
     }
     return $_data;
 }
开发者ID:Saltly,项目名称:SourceBans,代码行数:25,代码来源:SourceBans.php

示例9: _processFrameworkData

 /**
  * @param $localeId
  *
  * @return array
  */
 private function _processFrameworkData($localeId)
 {
     $wideMonthKeys = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     $abbreviatedMonthKeys = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
     $wideWeekdayNameKeys = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
     $abbreviatedWeekdayNameKeys = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
     $formattedFrameworkData = array();
     $locale = \CLocale::getInstance($localeId);
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideMonthKeys, $locale->getMonthNames()));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedMonthKeys, $locale->getMonthNames('abbreviated')));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideWeekdayNameKeys, $locale->getWeekDayNames()));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedWeekdayNameKeys, $locale->getWeekDayNames('abbreviated')));
     // Because sometimes Twig (ultimately PHP) will return 'pm' or 'am' and sometimes it will return 'PM' or 'AM'
     // and array indexes are case sensitive.
     $amName = $locale->getAMName();
     $pmName = $locale->getPMName();
     $formattedFrameworkData['AM'] = $amName;
     $formattedFrameworkData['am'] = $amName;
     $formattedFrameworkData['PM'] = $pmName;
     $formattedFrameworkData['pm'] = $pmName;
     return $formattedFrameworkData;
 }
开发者ID:nitwitt10,项目名称:Trove,代码行数:27,代码来源:PhpMessageSource.php

示例10: resolveMergeTagToStandardOrRelatedAttribute

 protected static function resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params)
 {
     $attributeName = strtok($attributeAccessorString, '->');
     if (SpecialMergeTagsAdapter::isSpecialMergeTag($attributeName, $timeQualifier)) {
         return SpecialMergeTagsAdapter::resolve($attributeName, $model, $errorOnFirstMissing, $params);
     } else {
         if (!isset($model)) {
             return static::PROPERTY_NOT_FOUND;
         } elseif (!method_exists($model, 'isAttribute') || !$model->isAttribute($attributeName)) {
             if ($model instanceof Activity) {
                 $metadata = $model::getMetadata();
                 $activityItemsModelClassNamesData = $metadata['Activity']['activityItemsModelClassNames'];
                 foreach ($model->activityItems as $activityItem) {
                     if (ucfirst($attributeName) == get_class($activityItem)) {
                         $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
                         return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $activityItem, $language, $timeQualifier, $errorOnFirstMissing, $params);
                     }
                     if (get_class($activityItem) == 'Item' && array_search(ucfirst($attributeName), $activityItemsModelClassNamesData) !== false) {
                         try {
                             $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem(ucfirst($attributeName));
                             $castedDownModel = $activityItem->castDown(array($modelDerivationPathToItem));
                             if (ucfirst($attributeName) == get_class($castedDownModel)) {
                                 $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
                                 return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $castedDownModel, $language, $timeQualifier, $errorOnFirstMissing, $params);
                             }
                         } catch (NotFoundException $e) {
                             //Do nothing
                         }
                     }
                     unset($activityItemsModelClassNamesData[get_class($activityItem)]);
                 }
                 foreach ($activityItemsModelClassNamesData as $relationModelClassName) {
                     if (ucfirst($attributeName) == $relationModelClassName) {
                         $model = new $relationModelClassName();
                         $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
                         return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params);
                     }
                 }
             }
             return static::PROPERTY_NOT_FOUND;
         } elseif ($model->{$attributeName} instanceof CurrencyValue) {
             $model = $model->{$attributeName};
             if ($attributeName === $attributeAccessorString) {
                 $attributeAccessorString = null;
             } else {
                 $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
             }
             if (empty($attributeAccessorString)) {
                 // If a user specific a relation merge tag but not a property, we assume he meant "value" property.
                 $currencyValueModel = $model;
                 $value = static::getAttributeValue($currencyValueModel, 'value', $timeQualifier);
                 return CLocale::getInstance($language)->getCurrencySymbol($currencyValueModel->currency->code) . $value;
                 // We can't use code below because it converts integer values in flat and also add slashes to '.' in float numbers
                 //return Yii::app()->numberFormatter->formatCurrency($value,
                 //    $currencyValueModel->currency->code);
             }
             return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params);
         } elseif ($model->{$attributeName} instanceof CustomField) {
             $value = static::getAttributeValue($model->{$attributeName}, 'value', $timeQualifier);
             // TODO: @Shoaibi/@Jason: Low: need to apply localizations(Date/time/currency formats, ...) here besides translation
             if ($value) {
                 $value = Zurmo::t($model::getModuleClassName(), $value, array(), null, $language);
             }
             return $value;
         } elseif ($model->isRelation($attributeName)) {
             $model = $model->{$attributeName};
             if ($attributeName === $attributeAccessorString) {
                 $attributeAccessorString = null;
             } else {
                 $attributeAccessorString = str_replace($attributeName . '->', '', $attributeAccessorString);
             }
             if (empty($attributeAccessorString)) {
                 // If a user specific a relation merge tag but not a property, we assume he meant "value" property.
                 if (empty($timeQualifier)) {
                     return strval($model);
                 } else {
                     return static::PROPERTY_NOT_FOUND;
                 }
             }
             if ($model instanceof RedBeanModels) {
                 $modelClassName = $model->getModelClassName();
                 if ($attributeAccessorString == lcfirst($modelClassName)) {
                     $values = array();
                     foreach ($model as $relatedModel) {
                         $values[] = strval($relatedModel);
                     }
                     return ArrayUtil::stringify($values);
                 }
             }
             return static::resolveMergeTagToStandardOrRelatedAttribute($attributeAccessorString, $model, $language, $timeQualifier, $errorOnFirstMissing, $params);
         } else {
             $attributeType = ModelAttributeToMixedTypeUtil::getType($model, $attributeName);
             //We don't have any accessor operator after the attributeName e.g. its the last in list
             if ($attributeName === $attributeAccessorString) {
                 $content = static::getAttributeValue($model, $attributeName, $timeQualifier);
                 if ($attributeType == 'DateTime') {
                     $content .= ' GMT';
                 }
                 return $content;
             } else {
//.........这里部分代码省略.........
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:MergeTagsToModelAttributesAdapter.php

示例11: getBlankTempTrans

 private function getBlankTempTrans($rownum, $invDate = null)
 {
     $comp = Company::model()->findbyPk(Yii::app()->user->getState('selectedCompanyId'));
     $per = Period::model()->findbyPk(Yii::app()->user->getState('selectedPeriodId'));
     $model = new TempTrans();
     $model->rownum = $rownum;
     $model->regDate = date('Y-m-d');
     if ($invDate == null) {
         $invDate = $model->regDate;
     }
     $model->invDate = $invDate;
     $model->changedBy = Yii::app()->user->getState('displayname');
     $model->dateChanged = $model->regDate;
     $model->periodNum = $per->lastPeriodTransNum + 1;
     $model->companyNum = $comp->lastAbsTransNum + 1;
     $model->notesheader = '';
     $model->fileInfo = '';
     $model->fileInfo = 1;
     $model->accountId = 0;
     $model->customerId = 0;
     $model->donorId = 0;
     $model->notes = '';
     $model->amountdebit = "";
     $model->amountcredit = "";
     $model->userId = Yii::app()->user->id;
     $model->save();
     $cLoc = CLocale::getInstance('en');
     $model->invDate = User::getDateFormatted($model->invDate, $cLoc);
     $model->regDate = User::getDateFormatted($model->regDate, $cLoc);
     $model->dateChanged = $model->regDate;
     return $model;
 }
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:32,代码来源:TransController.php

示例12: CDateFormatter

?>
</th>
    <th><?php 
echo $sort->link('dateChanged');
?>
</th>
    <th><?php 
echo CHtml::encode(Yii::t('lazy8', 'Actions'));
?>
</th>

  </tr>
  </thead>
  <tbody>
<?php 
$cLoc = CLocale::getInstance('en');
$dateformatter = new CDateFormatter($cLoc);
foreach ($models as $n => $model) {
    ?>
  <tr class="<?php 
    echo $n % 2 ? 'even' : 'odd';
    ?>
">
    <td><?php 
    echo CHtml::encode($model->code);
    ?>
</td>
    <td><?php 
    echo CHtml::encode($model->name);
    ?>
</td>
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:31,代码来源:admin.php

示例13: getLanguages

 public function getLanguages()
 {
     if ($this->_languages === null) {
         $basePath = Yii::getPathOfAlias('application.data.guide') . DIRECTORY_SEPARATOR . $this->getVersion();
         $dir = opendir($basePath);
         $this->_languages = array('en' => 'English');
         if ($this->language !== 'en') {
             $this->_languages['en'] .= ' (' . CLocale::getInstance($this->language)->getLocaleDisplayName('en') . ')';
         }
         while (($file = readdir($dir)) !== false) {
             if (!is_dir($basePath . DIRECTORY_SEPARATOR . $file) || $file === '.' || $file === '..' || $file === 'source') {
                 continue;
             }
             $this->_languages[$file] = CLocale::getInstance($file)->getLocaleDisplayName($file);
             if ($file !== $this->language) {
                 $this->_languages[$file] .= ' (' . CLocale::getInstance($this->language)->getLocaleDisplayName($file) . ')';
             }
         }
         ksort($this->_languages);
     }
     return $this->_languages;
 }
开发者ID:Saltly,项目名称:SourceBans,代码行数:22,代码来源:GuideController.php

示例14: actionReport


//.........这里部分代码省略.........
             echo '<h2>Died on Sql execution</h2>' . $sqlSelect;
             throw $e;
         }
         $imageFileNames = array();
         $imageFilePaths = array();
         if (strlen($graphicFilename) > 0) {
             $images = $this->readXmlGraphicFile($graphicFilename, false, $reader, $title, $negateGraphicValues, $imageFileNames);
             $imageFileNames = $images[1];
             $imageFilePaths = $images[0];
             //must do this again because the reader can only go forwards
             $reader = $command->query();
         }
         //update last used report for printout
         $printoutview = "";
         if (isset($_POST['printoutview'])) {
             $printoutview = $_POST['printoutview'];
         }
         $option = Options::model()->find('name=\'isReportForPrintout\' AND companyId=0 AND userId=' . Yii::app()->user->id);
         $option->datavalue = $printoutview == 1 ? 'true' : 'false';
         $option->save();
         Yii::app()->user->setState('isReportForPrintout', $printoutview);
         //update last used black and white
         $option = Options::model()->find('name=\'isReportBlackAndWhite\' AND companyId=0 AND userId=' . Yii::app()->user->id);
         $option->datavalue = false;
         $option->datavalue = isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1 ? 'true' : 'false';
         $option->save();
         Yii::app()->user->setState('isReportBlackAndWhite', isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1 ? 1 : 0);
         if (isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1) {
             Yii::app()->user->setState('reportCssFile', $this->_model->cssBwFileName);
         } else {
             Yii::app()->user->setState('reportCssFile', $this->_model->cssColorFileName);
         }
         //get the number and date formats
         $cLoc = CLocale::getInstance('en');
         $numberFormatter = $cLoc->getNumberFormatter();
         $dateFormatter = $cLoc->getDateFormatter();
         // echo "<pre>";
         // var_dump($dateFormatter);
         // echo "</pre>";
         // die();
         $numberFormat = User::getNumberFormat();
         $pdf_name = "";
         $cron_job = FALSE;
         // if from cron job
         if (isset($_POST['cron'])) {
             $pdf_name = "reports/lazy8report_" . date('Y-m-d_H.i.s');
             $cron_job = TRUE;
         }
         if (isset($_POST['DownloadExcel'])) {
             Yii::import('application.controllers.excel.*');
             require_once "exportExcel.php";
             new exportExcel($this->_model, $reader, $pdf_name, $numberFormatter, $dateFormatter, $numberFormat, $printoutview, $parameterValues);
             die;
         } else {
             if (isset($_POST['DownloadPDF'])) {
                 // var_dump($numberFormat);
                 // die();
                 Yii::import('application.controllers.tcpdf.*');
                 require_once "lazy8tcpdf.php";
                 new lazy8tcpdf($this->_model, $reader, $pdf_name, $cron_job, $numberFormatter, $dateFormatter, $numberFormat, $printoutview, $parameterValues, $imageFileNames, isset($_POST['blackandwhite']) && $_POST['blackandwhite'] == 1 ? 1 : 0, strpos(Yii::app()->user->getState('reportCssFile'), "wide") === false);
                 // if cron job was run then email user with the pdf attatchment
                 if (isset($_POST['cron'])) {
                     $accountID = $_POST['accountID'];
                     $sql = "SELECT Account.code AS accountcode, Account.name AS accountname, Account.email AS email, Account.balance_threshold AS threshold, Account.days AS days\n\t\t\t\t\t\t\t\tFROM Account\n\t\t\t\t\t\t\t\tWHERE Account.code = '{$accountID}'";
                     $account = Yii::app()->db->createCommand($sql)->queryAll();
                     $to = $account['email'];
开发者ID:Jride,项目名称:accounting-thaiconnections,代码行数:67,代码来源:ReportController.php

示例15: _processFrameworkData

 /**
  * @param $localeId
  *
  * @return array
  */
 private function _processFrameworkData($localeId)
 {
     $wideMonthKeys = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
     $abbreviatedMonthKeys = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
     $wideWeekdayNameKeys = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
     $abbreviatedWeekdayNameKeys = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
     $amNameKey = 'AM';
     $pmNameKey = 'PM';
     $formattedFrameworkData = array();
     $locale = \CLocale::getInstance($localeId);
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideMonthKeys, $locale->getMonthNames()));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedMonthKeys, $locale->getMonthNames('abbreviated')));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($wideWeekdayNameKeys, $locale->getWeekDayNames()));
     $formattedFrameworkData = array_merge($formattedFrameworkData, array_combine($abbreviatedWeekdayNameKeys, $locale->getWeekDayNames('abbreviated')));
     $formattedFrameworkData[$amNameKey] = $locale->getAMName();
     $formattedFrameworkData[$pmNameKey] = $locale->getPMName();
     return $formattedFrameworkData;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:23,代码来源:PhpMessageSource.php


注:本文中的CLocale::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。