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


PHP Lang::setLanguage方法代码示例

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


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

示例1: profile

 /**
  * Allows the user to edit their profile.
  * @return string
  */
 public function profile()
 {
     $user = $_SESSION['phpci_user'];
     if ($this->request->getMethod() == 'POST') {
         $name = $this->getParam('name', null);
         $email = $this->getParam('email', null);
         $password = $this->getParam('password', null);
         $currentLang = Lang::getLanguage();
         $chosenLang = $this->getParam('language', $currentLang);
         if ($chosenLang !== $currentLang) {
             setcookie('phpcilang', $chosenLang, time() + 10 * 365 * 24 * 60 * 60, '/');
             Lang::setLanguage($chosenLang);
         }
         $_SESSION['phpci_user'] = $this->userService->updateUser($user, $name, $email, $password);
         $user = $_SESSION['phpci_user'];
         $this->view->updated = 1;
     }
     $this->layout->title = $user->getName();
     $this->layout->subtitle = Lang::get('edit_profile');
     $values = $user->getDataArray();
     if (array_key_exists('phpcilang', $_COOKIE)) {
         $values['language'] = $_COOKIE['phpcilang'];
     }
     $form = new Form();
     $form->setAction(PHPCI_URL . 'user/profile');
     $form->setMethod('POST');
     $name = new Form\Element\Text('name');
     $name->setClass('form-control');
     $name->setContainerClass('form-group');
     $name->setLabel(Lang::get('name'));
     $name->setRequired(true);
     $form->addField($name);
     $email = new Form\Element\Email('email');
     $email->setClass('form-control');
     $email->setContainerClass('form-group');
     $email->setLabel(Lang::get('email_address'));
     $email->setRequired(true);
     $form->addField($email);
     $password = new Form\Element\Password('password');
     $password->setClass('form-control');
     $password->setContainerClass('form-group');
     $password->setLabel(Lang::get('password_change'));
     $password->setRequired(false);
     $form->addField($password);
     $lang = new Form\Element\Select('language');
     $lang->setClass('form-control');
     $lang->setContainerClass('form-group');
     $lang->setLabel(Lang::get('language'));
     $lang->setRequired(true);
     $lang->setOptions(Lang::getLanguageOptions());
     $lang->setValue(Lang::getLanguage());
     $form->addField($lang);
     $submit = new Form\Element\Submit();
     $submit->setClass('btn btn-success');
     $submit->setValue(Lang::get('save'));
     $form->addField($submit);
     $form->setValues($values);
     $this->view->form = $form;
     return $this->view->render();
 }
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:64,代码来源:UserController.php

示例2: date_default_timezone_set

*
* @copyright    Copyright 2013, Block 8 Limited.
* @license      https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link         http://www.phptesting.org/
*/
// Let PHP take a guess as to the default timezone, if the user hasn't set one:
date_default_timezone_set(@date_default_timezone_get());
// Load Composer autoloader:
require_once dirname(__DIR__) . '/vendor/autoload.php';
// If the PHPCI config file is not where we expect it, try looking in
// env for an alternative config path.
$configFile = dirname(__FILE__) . '/../PHPCI/config.yml';
if (!file_exists($configFile)) {
    $configEnv = getenv('phpci_config_file');
    if (!empty($configEnv)) {
        $configFile = $configEnv;
    }
}
// Load configuration if present:
$conf = array();
$conf['b8']['app']['namespace'] = 'PHPCI';
$conf['b8']['app']['default_controller'] = 'Home';
$conf['b8']['view']['path'] = dirname(__DIR__) . '/PHPCI/View/';
$config = new b8\Config($conf);
if (file_exists($configFile)) {
    $config->loadYaml($configFile);
}
require_once dirname(__DIR__) . '/vars.php';
\PHPCI\Helper\Lang::init($config);
\PHPCI\Helper\Lang::setLanguage("en");
开发者ID:ntoniazzi,项目名称:PHPCI,代码行数:30,代码来源:bootstrap.php


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