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


PHP X_Env::initTranslator方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     $lang = $this->getRequest()->getParam('lang', false);
     $languages = array();
     foreach (new DirectoryIterator(APPLICATION_PATH . "/../languages/") as $entry) {
         if ($entry->isFile() && pathinfo($entry->getFilename(), PATHINFO_EXTENSION) == 'ini') {
             if (count(explode('.', $entry->getFilename())) == 2) {
                 $languages[$entry->getFilename()] = pathinfo($entry->getFilename(), PATHINFO_FILENAME);
             }
         }
     }
     if ($lang != false) {
         // cleanup from ./ and ../
         $lang = str_replace(array('.', '/'), '', $lang);
         if (file_exists(APPLICATION_PATH . "/../languages/{$lang}.ini") && array_key_exists("{$lang}.ini", $languages)) {
             $translation = new Zend_Translate('ini', APPLICATION_PATH . "/../languages/{$lang}.ini");
             X_Env::initTranslator($translation);
         } else {
             $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('installer_invalid_language')));
             $lang = false;
         }
     }
     $form = new Application_Form_Installer();
     $form->setAction($this->_helper->url('save', 'installer'));
     try {
         $form->lang->setMultiOptions($languages);
         $form->setDefault('lang', $lang !== false ? "{$lang}.ini" : 'en_GB.ini');
         $form->setDefault('auth', 0);
         $form->setDefault('threads', X_Env::completeUrl($this->_helper->url('start', 'threads')));
     } catch (Exception $e) {
         // WTF?
     }
     // try to read the manifest of plugins index
     $plugins = $this->getInstallablePlugins();
     try {
         $form->plugins->setMultiOptions($plugins);
     } catch (Exception $e) {
         // Connection kaboom?
     }
     $ns = new Zend_Session_Namespace('vlc-shares::installer');
     if (isset($ns->errors) && $ns->errors) {
         $form->isValid($ns->data);
         unset($ns->errors);
         unset($ns->data);
     }
     $threadsChecks = $this->_helper->url('check', 'threads');
     $threadsPing = $this->_helper->url('ping', 'threads');
     $basePing = $this->_helper->url('', 'threads');
     $httpPort = $_SERVER['SERVER_PORT'];
     $httpPort = $httpPort != '80' && $httpPort != '' ? ":{$httpPort}" : '';
     $threadsUrls = array("'http://localhost{$httpPort}{$basePing}'", "'http://127.0.0.1{$httpPort}{$basePing}'", "'http://127.0.1.1{$httpPort}{$basePing}'", "'http://192.168.1.1{$httpPort}{$basePing}'");
     $this->view->messages = array_merge($this->_helper->flashMessenger->getMessages(), $this->_helper->flashMessenger->getCurrentMessages());
     $this->_helper->flashMessenger->clearCurrentMessages();
     $this->view->languages = $languages;
     $this->view->threadsCheck = $threadsChecks;
     $this->view->threadsPing = $threadsPing;
     $this->view->threadsUrls = $threadsUrls;
     $this->view->form = $form;
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:59,代码来源:InstallerController.php

示例2: addTranslation

 public function addTranslation($key)
 {
     $moduleName = $key . '.' . $this->lang;
     // i have to check $moduleName to be sure that the file is inside the languages/ directory
     if (file_exists(realpath(APPLICATION_PATH . "/../languages/{$moduleName}"))) {
         $translate = new Zend_Translate('ini', realpath(APPLICATION_PATH . "/../languages/{$moduleName}"));
     } elseif ($this->lang != 'en_GB.ini' && file_exists(realpath(APPLICATION_PATH . "/../languages/{$key}.en_GB.ini"))) {
         // fallback to english translation
         X_Debug::w("Language file not found: {$moduleName}. Falling back to english translation");
         $translate = new Zend_Translate('ini', realpath(APPLICATION_PATH . "/../languages/{$key}.en_GB.ini"));
     } else {
         X_Debug::w("Language file not found: {$moduleName}");
         return false;
     }
     // time to append translator to the global instance
     X_Env::initTranslator($translate);
     return true;
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:18,代码来源:Language.php

示例3: _initTranslation

 protected function _initTranslation()
 {
     $this->bootstrap('configs');
     $this->bootstrap('debug');
     $configs = $this->getResource('configs');
     $translation = null;
     if ($configs instanceof Zend_Config) {
         try {
             $translation = new Zend_Translate('ini', APPLICATION_PATH . "/../languages/" . $configs->general->get('languageFile', "en_GB.ini"));
             X_Env::initTranslator($translation);
         } catch (Exception $e) {
             // no translation available
             X_Debug::e("Translation disabled: {$e->getMessage()}");
         }
     }
     return $translation;
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:17,代码来源:Bootstrap.php


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