• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP CChoiceFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: t

 /**
  * Translates a message to the specified language.
  * Starting from version 1.0.2, this method supports choice format (see {@link CChoiceFormat}),
  * i.e., the message returned will be chosen from a few candidates according to the given
  * number value. This feature is mainly used to solve plural format issue in case
  * a message has different plural forms in some languages.
  * @param string message category. Please use only word letters. Note, category 'yii' is
  * reserved for Yii framework core code use. See {@link CPhpMessageSource} for
  * more interpretation about message category.
  * @param string the original message
  * @param array parameters to be applied to the message using <code>strtr</code>.
  * Starting from version 1.0.2, the first parameter can be a number without key.
  * And in this case, the method will call {@link CChoiceFormat::format} to choose
  * an appropriate message translation.
  * @param string which message source application component to use.
  * Defaults to null, meaning using 'coreMessages' for messages belonging to
  * the 'yii' category and using 'messages' for the rest messages.
  * @param string the target language. If null (default), the {@link CApplication::getLanguage application language} will be used.
  * This parameter has been available since version 1.0.3.
  * @return string the translated message
  * @see CMessageSource
  */
 public static function t($category, $message, $params = array(), $source = null, $language = null)
 {
     if (self::$_app !== null) {
         if ($source === null) {
             $source = $category === 'yii' || $category === 'zii' ? 'coreMessages' : 'messages';
         }
         if (($source = self::$_app->getComponent($source)) !== null) {
             $message = $source->translate($category, $message, $language);
         }
     }
     if ($params === array()) {
         return $message;
     }
     if (isset($params[0])) {
         $message = CChoiceFormat::format($message, $params[0]);
         unset($params[0]);
     }
     return $params !== array() ? strtr($message, $params) : $message;
 }
开发者ID:kscott,项目名称:checkin-proto,代码行数:41,代码来源:YiiBase.php


示例2: t

 public static function t($category, $message, $params = array(), $source = null, $language = null)
 {
     if (self::$_app !== null) {
         if ($source === null) {
             $source = $category === 'yii' || $category === 'zii' ? 'coreMessages' : 'messages';
         }
         if (($source = self::$_app->getComponent($source)) !== null) {
             $message = $source->translate($category, $message, $language);
         }
     }
     if ($params === array()) {
         return $message;
     }
     if (!is_array($params)) {
         $params = array($params);
     }
     if (isset($params[0])) {
         if (strpos($message, '|') !== false) {
             if (strpos($message, '#') === false) {
                 $chunks = explode('|', $message);
                 $expressions = self::$_app->getLocale($language)->getPluralRules();
                 if ($n = min(count($chunks), count($expressions))) {
                     for ($i = 0; $i < $n; $i++) {
                         $chunks[$i] = $expressions[$i] . '#' . $chunks[$i];
                     }
                     $message = implode('|', $chunks);
                 }
             }
             $message = CChoiceFormat::format($message, $params[0]);
         }
         if (!isset($params['{n}'])) {
             $params['{n}'] = $params[0];
         }
         unset($params[0]);
     }
     return $params !== array() ? strtr($message, $params) : $message;
 }
开发者ID:smokeelow,项目名称:faicore,代码行数:37,代码来源:yiilite.php


示例3: getGeocodingInfo

 /**
  * 
  * Connection to Google Maps' API web service
  * 
  * Modified to include a template for api
  * just in case the url changes in future releases
  * Includes template parsing and CURL calls
  * @author Antonio Ramirez Cobos
  * @since 2010-12-21
  * 
  * @param string $address
  * @param string $format 'csv' or 'xml'
  * @return string
  * @author fabriceb
  * @since 2009-06-17
  * @since 2010-12-22 cUrl and Yii adaptation Antonio Ramirez
  * 
  */
 public function getGeocodingInfo($address, $format = 'csv')
 {
     $apiUrl = CChoiceFormat::format($this->geoCodingInfotemplate, array('{api}' => self::API_URL, '{format}' => $format, '{key}' => $this->getAPIKey(), '{address}' => urlencode($address)));
     $apiURL = self::API_URL . '&output=' . $format . '&key=' . $this->getAPIKey() . '&q=' . urlencode($address);
     if (function_exists('curl_version')) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $apiURL);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
         //	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $raw_data = curl_exec($ch);
         curl_close($ch);
     } else {
         // no CUrl, try differently
         $raw_data = file_get_contents($apiURL);
     }
     return $raw_data;
 }
开发者ID:romeo14,项目名称:pow,代码行数:38,代码来源:EGMapClient.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP CClipWidget类代码示例发布时间:2022-05-23
下一篇:
PHP CCatalogStore类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap