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


PHP i18n::get方法代码示例

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


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

示例1: action_spam

 public function action_spam()
 {
     $id = (int) $this->request->param('id', 0);
     $question = ORM::factory('Feedback_Question', $id);
     $user_id = $this->user->id;
     if (!$question->loaded()) {
         $this->redirect('manage/feedback');
     }
     $token = Arr::get($_POST, 'token', false);
     $return = Security::xss_clean(Arr::get($_GET, 'r', 'manage/expert'));
     $this->set('return', Url::media($return));
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $question->is_spam = ($question->is_spam + 1) % 2;
         $question->spam_mod_id = $user_id;
         $question->save();
         if ($question->is_spam == 1) {
             Message::success(i18n::get('The question is marked as spam'));
         } else {
             Message::success(i18n::get('Marked "Spam" is removed from the question'));
         }
         $this->redirect($return);
     } else {
         if ($question->loaded()) {
             $this->set('question', $question)->set('token', Security::token(true));
         } else {
             $this->redirect('manage/expert');
         }
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:29,代码来源:Feedback.php

示例2: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id', 0);
     $opinion = ORM::factory('Expert_Opinion', $id);
     $experts = ORM::factory('Expert')->order_by('name_' . I18n::$lang)->find_all();
     $user_id = $this->user->id;
     $this->set('opinion', $opinion);
     $this->set('experts', $experts);
     if ($this->request->method() == Request::POST) {
         try {
             $opinion->expert_id = Arr::get($_POST, 'expert_id', '');
             $opinion->title = Arr::get($_POST, 'title', '');
             $opinion->description = Arr::get($_POST, 'description', '');
             $opinion->text = Arr::get($_POST, 'text', '');
             $opinion->protected = Arr::get($_POST, 'protected', '');
             $opinion->date = date('Y-m-d H:i:s');
             $opinion->user_id = $user_id;
             $opinion->save();
             $event = $id ? 'edit' : 'create';
             $loger = new Loger($event, $opinion->title);
             $loger->logThis($opinion);
             Message::success(i18n::get('The position of an expert retained'));
             $this->redirect('manage/expertopinions/view/' . $opinion->id . '/page-' . $this->page);
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors($e->alias());
             foreach ($errors as $key => $item) {
                 $errors[preg_replace("/(_ru|_kz|_en)/", '', $key)] = preg_replace("/(_ru|_kz|_en)/", '', $item);
             }
             $this->set('opinion', $_POST);
             $this->set('errors', $errors);
         }
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:33,代码来源:Expertopinions.php

示例3: __

function __($string, array $values = NULL)
{
    if (i18n::$lang !== i18n::$default_lang) {
        // Get the translation for this string
        $string = i18n::get($string);
    }
    return empty($values) ? $string : strtr($string, $values);
}
开发者ID:ukd1,项目名称:kohana,代码行数:8,代码来源:index.php

示例4: delete

 public function delete($type)
 {
     var_dump($this);
     die;
     CategoryItemModel::load()->delete('Post_ID', Input::get('id'));
     UploadItemModel::load()->delete('Post_ID', Input::get('id'));
     PostModel::load($type)->delete('ID', Input::get('id'));
     Session::set('SUCCESS', i18n::get('FEEDBACK_SUCCESS', 'system'));
     Redirect::to($this->project_url . "admin/read/post/{$type}/");
 }
开发者ID:peterbrinck,项目名称:PHPMvcCms,代码行数:10,代码来源:PostController.php

示例5: action_index

 public function action_index()
 {
     $briefings = ORM::factory('Briefing')->where('published', '=', 1)->order_by('date', 'DESC');
     $paginate = Paginate::factory($briefings)->paginate(NULL, NULL, 10)->render();
     $briefings = $briefings->find_all();
     $this->add_cumb('Briefings', '/');
     $this->set('briefings', $briefings);
     $this->set('paginate', $paginate);
     /* метатэг description */
     $this->metadata->description(i18n::get('Брифинги по вопросам изучения истории Казахстана'));
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:11,代码来源:Briefings.php

示例6: 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

示例7: action_page

 public function action_page()
 {
     $id = (int) $this->request->param('id', 0);
     $publication = ORM::factory('Publication', $id);
     if (!$publication->loaded()) {
         throw new HTTP_Exception_404();
     }
     $this->add_cumb(i18n::get('Тайны казахских орнаментов'), 'ornek');
     $this->add_cumb($publication->title, 'ornek');
     $this->set('item', $publication);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:11,代码来源:Ornek.php

示例8: getList

 function getList()
 {
     $application = Application::getInstance();
     $registry = Registry::getInstance();
     $i18n = new i18n($registry->get('i18n_path') . 'router.xml');
     $renderer = new Renderer(Page::MODE_NORMAL);
     $pTitle = $i18n->get('title');
     $renderer->page->set('title', $pTitle)->set('h1', $pTitle)->set('content', RouterListView::get(['list' => Router::getList()]));
     $renderer->loadPage();
     $renderer->output();
 }
开发者ID:jne21,项目名称:WBT,代码行数:11,代码来源:RouterController.php

示例9: action_index

 public function action_index()
 {
     $courses = ORM::factory('Education')->where('language', '=', $this->language)->where('published', '=', 1)->order_by('number');
     $paginate = Paginate::factory($courses)->paginate(NULL, NULL, 30)->render();
     $courses = $courses->find_all();
     $this->set('paginate', $paginate);
     $this->set('courses', $courses);
     $this->add_cumb('Цифровые образовательные ресурсы', false);
     /* метатэг description */
     $this->metadata->description(i18n::get('Цифровые образовательные ресурсы, интерактивные материалы, интерактивные тесты'));
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:11,代码来源:Scorm.php

示例10: action_add

 public function action_add()
 {
     $search = $this->request->param('string', "");
     $id = $this->request->param('material_id', 0);
     $id_project = $this->request->param('project_id', 0);
     $type = $this->request->param('type', 0);
     $article = ORM::factory('Material_Project');
     $article->material_id = $id;
     $article->project_id = $id_project;
     $article->type = $type;
     $article->save();
     Message::success(i18n::get('Материал успешно добавлен в спец.проект!'));
     $this->redirect('manage/search/' . $id_project . '/all/' . $search);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:14,代码来源:Searchadd.php

示例11: __construct

 public function __construct()
 {
     // construct controller
     parent::__construct();
     // set urls
     $this->data['project_url'] = Router::getProjectUrl();
     $this->data['current_url'] = Router::getUrl();
     // set date format
     $this->data['date_format'] = App::load()->date_format;
     //set admin nav
     App::load()->register('nav', array(" \n  <div class='list-group panel'> \n    <a href='#post' class='list-group-item list-group-item-info' data-toggle='collapse'>" . i18n::get('POST_HEADER', 'post') . "</a> \n    <div class='collapse' id='post'> \n       <a href='" . $this->data['project_url'] . "admin/read/post/article/' class='list-group-item'>" . i18n::get('POST_SUB_HEADER', 'post') . "</a> \n      <a href='" . $this->data['project_url'] . "admin/create/post/article/' class='list-group-item'>" . i18n::get('POST_CREATE', 'post') . "</a> \n    </div> \n  </div>"));
     // set default includes
     $this->header = PATH_APP_VIEWS . 'admin/default/assets/inc/_header';
     $this->sidebar = PATH_APP_VIEWS . 'admin/default/assets/inc/_sidebar';
     $this->footer = PATH_APP_VIEWS . 'admin/default/assets/inc/_footer';
 }
开发者ID:peterbrinck,项目名称:PHPMvcCms,代码行数:16,代码来源:AdminController.php

示例12: main

 public function main()
 {
     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);
     } catch (Exception $e) {
         Tools_Exceptionhandler::topDeal($e);
     }
 }
开发者ID:hiloy,项目名称:autophp,代码行数:20,代码来源:demo.php

示例13: action_edit

 public function action_edit()
 {
     $id = $this->request->param('id', 0);
     $expert = ORM::factory('Expert', $id);
     if ($expert->loaded()) {
         $flag = true;
     } else {
         $flag = false;
     }
     $user_id = $this->user->id;
     $uploader = View::factory('storage/image')->set('user_id', $user_id)->render();
     $this->set('uploader', $uploader);
     $this->set('expert', $expert);
     $this->set('page', $this->page);
     if ($this->request->method() == Request::POST) {
         try {
             $expert->name = Arr::get($_POST, 'name', '');
             $expert->image = (int) Arr::get($_POST, 'image', '');
             $expert->description = Arr::get($_POST, 'description', '');
             $expert->position = Arr::get($_POST, 'position', '');
             $expert->date = date('Y-m-d H:i:s');
             $expert->user_id = $user_id;
             $expert->save();
             if (!$flag) {
                 $list = ORM::factory('Expert');
                 $paginate = Paginate::factory($list);
                 $list = $list->find_all();
                 $this->page = $paginate->page_count();
             }
             Message::success(i18n::get('The expert retained'));
             $this->redirect('manage/expert/view/' . $expert->id . '/page-' . $this->page);
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors($e->alias());
             foreach ($errors as $key => $item) {
                 $errors[preg_replace("/(_ru|_kz|_en)/", '', $key)] = preg_replace("/(_ru|_kz|_en)/", '', $item);
             }
             $this->set('expert', $_POST);
             $this->set('errors', $errors);
         }
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:41,代码来源:Expert.php

示例14: action_index

 public function action_index()
 {
     $this->add_cumb(i18n::get("Мультимедиа"), '');
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:4,代码来源:Multimedia.php

示例15: validate

 function validate($values = null)
 {
     $values = pick($values, $this->populate());
     foreach ($this->schema as $field) {
         $input_id = $this->model_name . '_' . $field->name;
         $input_value = $values[$input_id];
         // Required error (not primary key, not foreign key and null or zero length string)
         if (!$field->primaryKey && !$field->foreignKey && $field->required && ($input_value === null || strlen($input_value) === 0)) {
             $this->errors[$input_id] = i18n::get('This field is required.');
             continue;
         } elseif (!$field->required && ($input_value === null || strlen($input_value) === 0)) {
             continue;
         }
         // Validate via regex, validation template or field type
         $regex = $field->regex ? 'regex' : null;
         $validation_type = pick($regex, $field->template, $field->type);
         switch ($validation_type) {
             // Regex matching
             case 'regex':
                 // Regex error
                 if (!preg_match($field->regex, $input_value)) {
                     $this->errors[$input_id] = i18n::get('Please type a valid value for this field.');
                     continue;
                 }
                 break;
                 // Numeric template
             // Numeric template
             case 'numeric':
             case 'int':
             case 'tinyint':
                 // Non-numeric error
                 if ($input_value !== null && !is_numeric($input_value)) {
                     $this->errors[$input_id] = i18n::get('This field accepts numbers only.');
                     continue;
                 }
                 break;
                 // E-mail template
             // E-mail template
             case 'email':
                 // E-mail error
                 $email_regex = '/^[a-zA-Z0-9._-]+@[a-zA-Z0-9][a-zA-Z0-9._-]+.[a-zA-Z0-9._-]{2,}$/';
                 if (!preg_match($email_regex, $input_value)) {
                     $this->errors[$input_id] = i18n::get('Please type a valid e-mail address.');
                     continue;
                 }
                 break;
                 // Currency template
             // Currency template
             case 'currency':
             case 'decimal':
                 // Currency error
                 $currency_regex = '/^[0-9,.]+$/';
                 if ($input_value !== null && !preg_match($currency_regex, $input_value)) {
                     $this->errors[$input_id] = i18n::get('Please type a valid amount.');
                     continue;
                 }
                 break;
                 // Field type: varchar, text
             // Field type: varchar, text
             case 'varchar':
             case 'text':
                 $length = strlen($input_value);
                 // Minlength error
                 if ($field->minlength && $length < $field->minlength) {
                     $this->errors[$input_id] = i18n::get('This field requires at least %0 characters.', array($field->minlength));
                     continue;
                 }
                 // Maxlength error
                 if ($field->maxlength && $length > $field->maxlength) {
                     $this->errors[$input_id] = i18n::get('This field\'s maximun length is %0 characters.', array($field->maxlength));
                 }
                 break;
             case 'datetime':
                 break;
             default:
                 print '<p><strong>Unhandled field type "' . $field->type . '"</strong></p>';
         }
     }
     if (count($this->errors) === 0) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:rev087,项目名称:kennel,代码行数:84,代码来源:ModelForm.php


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