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


PHP i18n::init方法代码示例

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


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

示例1: init

 public static function init($debug = false)
 {
     define('FATAL', E_USER_ERROR);
     define('ERROR', E_USER_WARNING);
     define('WARNING', E_USER_NOTICE);
     try {
         include "framework" . DS . "bootstrap.php";
         $error = new ErrorHandler();
         $config = Config::getInstance();
         $baseURL = $config->getbaseurl();
         if (!defined("BASE_URL")) {
             define("BASE_URL", $baseURL);
         }
         $filter = BaseFilter::getInstance();
         new Request();
         $i18n = i18n::init();
         Router::getInstance();
         new Dispatcher();
     } catch (Exception $ex) {
         trigger_error("CORE | There has been an exception at the core of the Framework {$ex->getMessage()} ", E_USER_ERROR);
     }
 }
开发者ID:andreums,项目名称:framework1.5,代码行数:22,代码来源:core.php

示例2: init

 /**
  * Initialize db connections, cache and session
  */
 public static function init($options = [])
 {
     // initialize mbstring
     mb_internal_encoding('UTF-8');
     mb_regex_encoding('UTF-8');
     // get flags & dependencies
     $flags = application::get('flag');
     $backend = application::get('numbers.backend', ['backend_exists' => true]);
     // processing wildcard first
     $wildcard = application::get('wildcard');
     $wildcard_keys = null;
     if (!empty($wildcard['enabled']) && !empty($wildcard['model'])) {
         $wildcard_keys = call_user_func($wildcard['model']);
         application::set(['wildcard', 'keys'], $wildcard_keys);
     }
     // initialize cryptography
     $crypt = application::get('crypt');
     if (!empty($crypt) && $backend) {
         foreach ($crypt as $crypt_link => $crypt_settings) {
             if (!empty($crypt_settings['submodule']) && !empty($crypt_settings['autoconnect'])) {
                 $crypt_object = new crypt($crypt_link, $crypt_settings['submodule'], $crypt_settings);
             }
         }
     }
     // create database connections
     $db = application::get('db');
     if (!empty($db) && $backend) {
         foreach ($db as $db_link => $db_settings) {
             if (empty($db_settings['autoconnect']) || empty($db_settings['servers']) || empty($db_settings['submodule'])) {
                 continue;
             }
             $connected = false;
             foreach ($db_settings['servers'] as $server_key => $server_values) {
                 $db_object = new db($db_link, $db_settings['submodule']);
                 // wildcards replaces
                 if (isset($wildcard_keys[$db_link])) {
                     $server_values['dbname'] = $wildcard_keys[$db_link]['dbname'];
                 }
                 // connecting
                 $server_values = array_merge2($server_values, $db_settings);
                 $db_status = $db_object->connect($server_values);
                 if ($db_status['success'] && $db_status['status']) {
                     $connected = true;
                     break;
                 }
             }
             // checking if not connected
             if (!$connected) {
                 throw new Exception('Unable to open database connection!');
             }
         }
     }
     // initialize cache
     $cache = application::get('cache');
     if (!empty($cache) && $backend) {
         foreach ($cache as $cache_link => $cache_settings) {
             if (empty($cache_settings['submodule']) || empty($cache_settings['autoconnect'])) {
                 continue;
             }
             $connected = false;
             foreach ($cache_settings['servers'] as $cache_server) {
                 $cache_object = new cache($cache_link, $cache_settings['submodule']);
                 $cache_status = $cache_object->connect($cache_server);
                 if ($cache_status['success']) {
                     $connected = true;
                     break;
                 }
             }
             // checking if not connected
             if (!$connected) {
                 throw new Exception('Unable to open cache connection!');
             }
         }
     }
     // if we are from command line we exit here
     if (!empty($options['__run_only_bootstrap'])) {
         return;
     }
     // initialize session
     $session = application::get('flag.global.session');
     if (!empty($session['start']) && $backend && !application::get('flag.global.__skip_session')) {
         session::start(isset($session['options']) ? $session['options'] : []);
     }
     // we need to get overrides from session and put them back to flag array
     $flags = array_merge_hard($flags, session::get('numbers.flag'));
     application::set('flag', $flags);
     // initialize i18n
     if ($backend) {
         $temp_result = i18n::init();
         if (!$temp_result['success']) {
             throw new Exception('Could not initialize i18n.');
         }
     }
     // format
     format::init();
     // including libraries that we need to auto include
     if (!empty($flags['global']['library'])) {
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:101,代码来源:bootstrap.php

示例3: die

    die("Keine SCRIPT_NAME vom Apache erhalten!");
}
$_SERVER["REQUEST_URI2"] = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["SCRIPT_NAME"]) - 10);
$p = strpos($_SERVER["REQUEST_URI2"], "?");
if (!$p) {
    $_SERVER["REQUEST_URIpure"] = $_SERVER["REQUEST_URI2"];
} else {
    $_SERVER["REQUEST_URIpure"] = substr($_SERVER["REQUEST_URI2"], 0, $p);
}
include_once $_ENV["basepath"] . "/app/code/classes/class.i18n.php";
include_once $_ENV["basepath"] . "/app/code/classes/class.fcache.php";
@session_start();
if (isset($_GET["_lang"])) {
    $_SESSION["language"] = $_GET["_lang"];
}
i18n::init(isset($_SESSION["language"]) ? $_SESSION["language"] : "de_DE", "install");
switch ($_SERVER["REQUEST_URIpure"]) {
    case "/":
    case "/index.php":
        include $_ENV["basepath"] . "/app/design/default/install/index.php";
        exit(1);
    case "/license":
        include $_ENV["basepath"] . "/app/design/default/install/license.php";
        exit(1);
    case "/install":
        if (isset($_POST["action"]) && $_POST["action"] == "write_config") {
            include $_ENV["basepath"] . "/app/design/default/install/install_page5.php";
            exit(1);
        }
        if (isset($_POST["status"]) && $_POST["status"] == "database_ok") {
            include $_ENV["basepath"] . "/app/design/default/install/install_page4.php";
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:routing.install.php

示例4: Exception

        if (file_exists($file)) {
            require $file;
            return true;
        }
    }
    if (isset($_GET["debug"])) {
        throw new Exception("Klasse " . $class_name . " kann nicht gefunden werden!");
    }
    return false;
});
srand();
SiteConfig::load(0);
Session::init();
$config = SiteConfig::get(0);
if (!isset($_ENV["baseurl"])) {
    $_ENV["baseurl"] = $config["baseurl"];
}
if (!isset($_ENV["baseurlpath"])) {
    $_ENV["baseurlpath"] = $config["baseurlpath"];
}
//Bugvermeidung
$_REQUEST = array_merge($_GET, $_POST);
i18n::init(isset($_GET["_lang"]) ? $_GET["_lang"] : (isset($config["language"]) ? $config["language"] : "de_DE"));
function get_path($file)
{
    return str_replace("//", "/", $_ENV["baseurlpath"] . $file);
}
function html($txt)
{
    return htmlentities($txt, 3, "UTF-8");
}
开发者ID:andreaskasper,项目名称:askbot_php,代码行数:31,代码来源:standard.php

示例5:

<?php

// include i18n class and initialize it
require_once 'i18n.class.php';
$i18n = new i18n('lang/lang_{LANGUAGE}.yml', 'langcache/', 'en');
// Parameters: language file path, cache dir, default language (all optional)
// init object: load language files, parse them if not cached, and so on.
$i18n->init();
?>

<!-- get applied language -->
<p>Applied Language: <?php 
echo $i18n->getAppliedLang();
?>
 </p>

<!-- get the cache path -->
<p>Cache path: <?php 
echo $i18n->getCachePath();
?>
</p>

<!-- Get some greetings -->
<p>A greeting: <?php 
echo L::greeting;
?>
</p>
<p>Something other: <?php 
echo L::category_somethingother;
?>
</p><!-- normally sections in the ini are seperated with an underscore like here. -->
开发者ID:gamespree,项目名称:i18n,代码行数:31,代码来源:yml-example.php

示例6: run

 /**
  * Main server procedure. index.php in the system's root calls this method by default.
  */
 public function run()
 {
     $db = Config::main()->getDbo();
     // Prepare necessities.
     $this->user = new ModelUser($db);
     if ($this->user->isLoggedIn()) {
         $this->user->restoreSession()->refreshSession();
     }
     Cache::init($db);
     Profiler::startSection('DiamondMVC');
     Profiler::startSection('Initiating i18n');
     logMsg('DiamondMVC: using compressed language file: ' . (Config::main()->get('DEBUG_MODE') ? 'yes' : 'no'), 1, false);
     i18n::init(Config::main()->get('DEBUG_MODE'));
     Profiler::endSection();
     // Load plugins
     Profiler::startSection('Load plugins');
     $this->plugins = Plugin::getPlugins();
     Profiler::endSection();
     Profiler::startSection('Load permissions');
     Permissions::init($db);
     Profiler::endSection();
     // Register field classes
     Profiler::startSection('Register fields');
     FormBuilder::registerFields();
     Profiler::endSection();
     $evt = new SystemBeforeRouteEvent();
     $this->trigger($evt);
     if (!$evt->isDefaultPrevented()) {
         Profiler::startSection('Routing');
         // Route requested controller
         if (isset($_REQUEST['control']) and !empty($_REQUEST['control'])) {
             $control = 'Controller' . str_replace('-', '_', $_REQUEST['control']);
             if (!class_exists($control)) {
                 $control = Config::main()->get('DEFAULT_CONTROLLER');
             }
         } else {
             $control = Config::main()->get('DEFAULT_CONTROLLER');
         }
         logMsg("DiamondMVC: routed controller to " . $control, 1, false);
         // Detect requested action, by default "main"
         if (isset($_REQUEST['action'])) {
             $action = $_REQUEST['action'];
         } else {
             $action = 'main';
         }
         $action = preg_replace('/[^A-z_]+/', '_', $action);
         logMsg("DiamondMVC: action is " . $action, 1, false);
         // Detect type of action. Currently possible: HTML, AJAX, JSON
         if (isset($_REQUEST['type'])) {
             $type = strToLower($_REQUEST['type']);
         } else {
             $type = 'html';
         }
         logMsg("DiamondMVC: request type is " . $type, 1, false);
         // Detect requested template. Ignored in JSON requests
         if (isset($_REQUEST['tpl'])) {
             $_REQUEST['tpl'] = trim($_REQUEST['tpl']);
             if (!empty($_REQUEST['tpl'])) {
                 $tpl = $_REQUEST['tpl'];
             } else {
                 $tpl = 'default';
             }
         } else {
             $tpl = 'default';
         }
         if (!file_exists(jailpath(DIAMONDMVC_ROOT . '/templates', $tpl))) {
             $tpl = 'default';
         }
         logMsg("DiamondMVC: jailed template is " . $tpl, 1, false);
         // Detect requested view
         if (isset($_REQUEST['view'])) {
             $view = $_REQUEST['view'];
         } else {
             $view = '';
         }
         logMsg("DiamondMVC: view is " . $view, 1, false);
         // The controller is the heart of the MVC system.
         logMsg("DiamondMVC: constructing controller", 1, false);
         $controller = new $control();
         // Before actually performing the action, we'll give plugins the chance to change the controller, action, view and template.
         logMsg("DiamondMVC: triggering pre-action event", 1, false);
         $this->controller = $controller;
         $this->action = $action;
         $this->view = $view;
         $this->tpl = $tpl;
         $evt = new SystemActionEvent($controller, $action, $view, $tpl);
         $this->trigger($evt);
         $contrller = $this->controller = $evt->controller;
         $action = $this->action = $evt->action;
         $view = $this->view = $evt->view;
         $tpl = $this->tpl = $evt->template;
         Profiler::endSection();
         logMsg("DiamondMVC: new controller is: Controller" . $controller->getName() . '; new action is: ' . $action . '; new view is: ' . $view . '; new type is: ' . $type, 1, false);
         Profiler::startSection('Perform action');
         $controller->action($action);
         Profiler::endSection();
         Profiler::startSection('Output');
//.........这里部分代码省略.........
开发者ID:Zyr93,项目名称:DiamondMVC,代码行数:101,代码来源:class_diamondmvc.php


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