當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。