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


PHP i18n::getLanguage方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     try {
         echo "\r\n <br /> hello, i'm indexAction in controller_index, nice 2 meet u! <br />\r\n ";
         echo "\r\n <br /> now set language to zh-cn! <br />\r\n ";
         i18n::setLanguage('en-us');
         echo "\r\n <br /> in english, my name is: " . i18n::get('author') . " <br />\r\n ";
         echo "\r\n <br /> now set language to zh-cn! <br />\r\n ";
         i18n::setLanguage('zh-cn');
         echo "\r\n <br /> in chinese, my name is: " . i18n::get('author') . " <br />\r\n ";
         $mDemo = new model_demo();
         $uin = 10000;
         $uinfo = $mDemo->getUserInfo($uin);
         $uinfo2 = $mDemo->getUserInfo2($uin);
         $update = $mDemo->updateInfo(6, 1);
         var_dump($uinfo, $uinfo2, $update);
         $confs = array('title' => 'page title', 'time' => date('Ymd H:i:s'), 'name' => 'ricolau');
         log::add('error', 'im test~!');
     } catch (exception_i18n $e) {
         //i18n 的异常,一般是由于语言包不存在
         $code = $e->getCode();
         if ($code == exception_i18n::type_language_not_exist) {
             echo "\r\n <br /> exception: language of " . i18n::getLanguage() . ' not exist!\\r\\n <br />';
         }
         echo $e->getMessage();
     } catch (Exception $e) {
         //如果实在还是有exception,那就捕捉到这里吧,ignore 忽略处理的话。代码继续执行 $this->render(),不会白页。
         //throw $e;  //如果把这个异常抛上去,当前页面就木有了,上层接收到的话自己处理就好了,比如报个异常啥的
         $code = $e->getCode();
         echo $e->getMessage();
     }
     //一般来说 render 这块儿可以不用 try 和 cache,只有 template 或 slot 不存在才会有异常而已。
     //但是建议和上面部分业务代码的try cache 结构分离,从而可以更好的决定,如果业务数据有问题,页面是否还继续render()
     try {
         //按变量单独 assign
         $this->assign('uinfo', $uinfo);
         $this->assign('updateresult', $update);
         //批量assign 一个数组可以!
         $this->massign($confs);
         $this->render();
     } catch (exception_render $e) {
         //一般来说这个exception  不会有,模板放好了就行了么
         $code = $e->getCode();
         if ($code == exception_render::type_tpl_not_exist) {
             echo '\\r\\n <br /> exception: template not exist!\\r\\n <br />';
         } elseif ($code == exception_render::type_slot_not_exist) {
             echo '\\r\\n <br /> exception: template not exist!\\r\\n <br />';
         }
         echo $e->getMessage();
     }
     // equals to $this->render('index', 'index');
     return;
     //绝对不要用 exit!!!!!
 }
开发者ID:gavinjx,项目名称:autophp,代码行数:54,代码来源:index2.php

示例2: _view

 /**
  * Display ZeroBin frontend.
  *
  * @access private
  * @return void
  */
 private function _view()
 {
     // set headers to disable caching
     $time = gmdate('D, d M Y H:i:s \\G\\M\\T');
     header('Cache-Control: no-store, no-cache, must-revalidate');
     header('Pragma: no-cache');
     header('Expires: ' . $time);
     header('Last-Modified: ' . $time);
     header('Vary: Accept');
     // label all the expiration options
     $expire = array();
     foreach ($this->_conf->getSection('expire_options') as $time => $seconds) {
         $expire[$time] = $seconds == 0 ? i18n::_(ucfirst($time)) : filter::time_humanreadable($time);
     }
     // translate all the formatter options
     $formatters = array_map(array('i18n', 'translate'), $this->_conf->getSection('formatter_options'));
     // set language cookie if that functionality was enabled
     $languageselection = '';
     if ($this->_conf->getKey('languageselection')) {
         $languageselection = i18n::getLanguage();
         setcookie('lang', $languageselection);
     }
     $page = new RainTPL();
     $page::$path_replace = false;
     // we escape it here because ENT_NOQUOTES can't be used in RainTPL templates
     $page->assign('CIPHERDATA', htmlspecialchars($this->_data, ENT_NOQUOTES));
     $page->assign('ERROR', i18n::_($this->_error));
     $page->assign('STATUS', i18n::_($this->_status));
     $page->assign('VERSION', self::VERSION);
     $page->assign('DISCUSSION', $this->_conf->getKey('discussion'));
     $page->assign('OPENDISCUSSION', $this->_conf->getKey('opendiscussion'));
     $page->assign('MARKDOWN', array_key_exists('markdown', $formatters));
     $page->assign('SYNTAXHIGHLIGHTING', array_key_exists('syntaxhighlighting', $formatters));
     $page->assign('SYNTAXHIGHLIGHTINGTHEME', $this->_conf->getKey('syntaxhighlightingtheme'));
     $page->assign('FORMATTER', $formatters);
     $page->assign('FORMATTERDEFAULT', $this->_conf->getKey('defaultformatter'));
     $page->assign('NOTICE', i18n::_($this->_conf->getKey('notice')));
     $page->assign('BURNAFTERREADINGSELECTED', $this->_conf->getKey('burnafterreadingselected'));
     $page->assign('PASSWORD', $this->_conf->getKey('password'));
     $page->assign('FILEUPLOAD', $this->_conf->getKey('fileupload'));
     $page->assign('BASE64JSVERSION', $this->_conf->getKey('base64version'));
     $page->assign('LANGUAGESELECTION', $languageselection);
     $page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages()));
     $page->assign('EXPIRE', $expire);
     $page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire'));
     $page->assign('EXPIRECLONE', !$this->_doesExpire || $this->_doesExpire && $this->_conf->getKey('clone', 'expire'));
     $page->assign('URLSHORTENER', $this->_conf->getKey('urlshortener'));
     $page->draw($this->_conf->getKey('template'));
 }
开发者ID:squarefractal,项目名称:ZeroBin,代码行数:55,代码来源:zerobin.php

示例3: array

?>
<br /><br />

######## hi, i'm /index/index template ################
<br /><br />

<?php 
$this->slot('index/section');
?>
<br /><br />


######## show i18n use here ################

current language is: <?php 
echo i18n::getLanguage();
?>
<br /><br />

the author's gender is:<?php 
echo i18n::get('gender');
?>
<br /><br />

and the vget of i18n is: <?php 
echo i18n::vget('telltime', array($title, $time));
?>
<br /><br />


开发者ID:gavinjx,项目名称:autophp,代码行数:28,代码来源:index.php


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