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


PHP I18n::loadPo方法代码示例

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


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

示例1: importPOFile

 public function importPOFile($lang = 'ara')
 {
     $this->autoRender = false;
     $localDir = App::path('locales');
     $localDir = $localDir[0];
     $localeImportFile = $localDir . $this->convertLangCodeFromCoreToSchool($lang) . DS . 'LC_MESSAGES' . DS . 'update.po';
     if (is_file($localeImportFile)) {
         //echo '<meta content="text/html; charset=utf-8" http-equiv="Content-Type">';
         $translations = I18n::loadPo($localeImportFile);
         $saveData = array();
         $counter = 0;
         foreach ($translations as $tKey => $tValue) {
             if (!empty($tKey)) {
                 $saveData[$counter]['eng'] = $tKey;
                 $saveData[$counter][$lang] = $tValue;
                 $counter++;
             }
         }
         $data = $this->Translation->find('all');
         if (!empty($data)) {
             foreach ($saveData as $tKey => $tValue) {
                 $conditions = array('Translation.eng' => $tValue['eng']);
                 if ($this->Translation->hasAny($conditions)) {
                     $this->Translation->recursive = -1;
                     $transData = $this->Translation->findByEng($tValue['eng'], array('id'));
                     $saveData[$tKey]['id'] = $transData['Translation']['id'];
                 }
             }
         }
         if ($this->Translation->saveAll($saveData)) {
             return $this->redirect(array('action' => 'index', $lang));
         }
     }
 }
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:34,代码来源:TranslationsController.php

示例2: beforeFilter

 public function beforeFilter()
 {
     $this->protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
     $this->port = $_SERVER['SERVER_PORT'] == 80 ? false : ':' . $_SERVER['SERVER_PORT'];
     if (defined('PORTAL_DOMAIN')) {
         $pieces = parse_url(Router::url($this->here, true));
         if (defined('PK_DOMAIN') && $pieces['host'] == PK_DOMAIN) {
             $this->domainMode = 'PK';
             // only certain actions are allowed in this domain
             // for other actions we are immediatly redirecting to PORTAL_DOMAIN
             if (stripos($_SERVER['REQUEST_URI'], '/dane/gminy/903') === 0) {
                 $url = substr($_SERVER['REQUEST_URI'], 15);
                 if ($url[0] == ',') {
                     $p = strpos($url, '/');
                     $url = $p === false ? '' : substr($url, $p);
                 }
                 $this->redirect($this->protocol . PK_DOMAIN . $this->port . $url);
                 die;
             }
             if (preg_match('/^(.*?)\\,([a-z0-9\\-]+)$/', $this->here, $match)) {
                 $this->redirect($this->protocol . PK_DOMAIN . $this->port . $match[1]);
                 die;
             }
             $_id = strtolower($this->request->params['plugin'] . '.' . $this->request->params['controller']);
             $cross_domain = (stripos($_SERVER['REQUEST_URI'], '/cross-domain-') === 0 or stripos($_SERVER['REQUEST_URI'], '/login') === 0 or stripos($_SERVER['REQUEST_URI'], '/logout') === 0);
             if (!in_array($_id, array('dane.gminy', 'dane.highstock_browser', 'powiadomienia.powiadomienia', 'subscriptions.subscriptions', 'pisma.pisma', 'pisma.szablony', 'zamowieniapubliczne.zamowieniapubliczne', 'finanse.gminy')) && !$cross_domain) {
                 $url = $_SERVER['REQUEST_URI'];
                 if ($url[0] == ',') {
                     $p = strpos($url, '/');
                     $url = $p === false ? '' : substr($url, $p);
                 }
                 return $this->redirect($this->protocol . PORTAL_DOMAIN . $this->port . $url);
             }
         } elseif ($pieces['host'] != PORTAL_DOMAIN) {
             $this->redirect($this->protocol . PORTAL_DOMAIN . $this->port . $this->here, 301);
             die;
         }
     }
     $this->response->header('Access-Control-Allow-Origin', $this->request->header('Origin'));
     $this->response->header('Access-Control-Allow-Credentials', true);
     $redirect = false;
     if ($this->Session->read('Auth.User.id') && $this->Session->read('Pisma.transfer_anonymous')) {
         $this->loadModel('Pisma.Pismo');
         $this->Pismo->transfer_anonymous($this->Session->read('previous_id'));
         $this->Session->delete('Pisma.transfer_anonymous');
         $redirect = true;
     }
     if ($redirect) {
         return $this->redirect($this->request->here);
     }
     # assigning translations for javascript use
     if ($this->params->plugin) {
         $path = ROOT . DS . APP_DIR . DS . 'Plugin' . DS . Inflector::camelize($this->params->plugin) . DS . 'Locale' . DS . Configure::read('Config.language') . DS . 'LC_MESSAGES' . DS . Inflector::underscore($this->params->plugin) . '.po';
     } else {
         $path = ROOT . DS . APP_DIR . DS . 'Locale' . DS . Configure::read('Config.language') . DS . 'LC_MESSAGES' . DS . 'default.po';
     }
     if (file_exists($path)) {
         $translations = I18n::loadPo($path);
         foreach ($translations as &$item) {
             $item = stripslashes($item);
             $item = preg_replace('/"/', '&quot;', $item);
         }
     } else {
         $translations = array();
     }
     $this->set('translation', $translations);
     parent::beforeFilter();
     $this->Auth->allow();
     $this->set('statusbarCrumbs', $this->statusbarCrumbs);
     $this->set('statusbarMode', $this->statusbarMode);
     $this->set('_APPLICATIONS', $this->getApplications());
     $this->set('_APPLICATION', $this->getApplication());
     $this->set('domainMode', $this->domainMode);
     //		// remember path for redirect if necessary
     //		if ( Router::url( null ) != '/null' ) { // hack for bug
     //			$this->Session->write( 'Auth.loginRedirect', Router::url( null, true ) );
     //		}
     // cross domain login
     $this->set('current_host', $_SERVER['HTTP_HOST']);
     if ($this->Session->check('crossdomain_login_token')) {
         $this->set('crossdomain_login_token', $this->Session->read('crossdomain_login_token'));
         $this->Session->delete('crossdomain_login_token');
     }
     if ($this->Session->check('crossdomain_logout')) {
         $this->set('crossdomain_logout', $this->Session->read('crossdomain_logout'));
         $this->Session->delete('crossdomain_logout');
     }
     $this->set('isAdmin', $this->hasUserRole('2'));
 }
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:89,代码来源:AppController.php


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