本文整理汇总了PHP中Translator::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::init方法的具体用法?PHP Translator::init怎么用?PHP Translator::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translator
的用法示例。
在下文中一共展示了Translator::init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trim
$page['lang-root'] .= $page['lang'] . '/';
}
if (!isset($page['path'])) {
$page['path'] = str_replace($sitewide['root'], '/', $sitewide['path']);
$page['path'] = str_replace('/' . $page['lang'] . '/', '/', $page['path']);
}
if (!isset($page['name'])) {
$page['name'] = trim(preg_replace('#\\.php$#', '', $page['path']), '/');
if (empty($page['name'])) {
$page['name'] = 'index';
}
}
if (isset($page['title'])) {
$page['title'] = $l10n->translate($page['title'], $page['name']);
}
$l10n->init();
$l10n->set_domain('layout');
$l10n->begin_html_translation();
?>
<!doctype html>
<!--[if IE 9]><html lang="<?php
echo !empty($page['lang']) ? $page['lang'] : 'en';
?>
" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="<?php
echo !empty($page['lang']) ? $page['lang'] : 'en';
?>
"><!--<![endif]-->
<head>
<meta charset="UTF-8">
示例2: foreach
foreach ($langues as $langue) {
if ($_GET['lang'] == $langue->code) {
$userLangue = $langue;
break;
}
}
}
}
}
$request->langue = $response->langue = $userLangue;
define('LANGUE', $request->langue->code);
define('BASE_URL_LANGUE', BASE_URL . $request->langue->code . '/');
ini_set('default_charset', CHARSET);
setlocale(LC_TIME, $request->langue->locale . '.' . mb_strtolower(CHARSET));
if (in_array('translations', $backoModules) && file_exists(ROOT . 'traductions.inc.php')) {
Translator::init($request->langue->code, DEFAULT_LANG);
}
require_once APPLICATION_ROOT . 'UrlFactory.php';
UrlSingleton::init(new UrlFactory(), $request->langue);
if (in_array('admins', $allowedModules) && (empty($_SESSION['admin']) || !($admin = DBFactory::get('admins')->get($_SESSION['admin'])) instanceof Admin) && $request->url != UrlFactory::module('admins', 'login') && $request->url != UrlFactory::module('admins', 'init')) {
Header::location(UrlFactory::module('admins', 'login'));
}
try {
if (!file_exists($file = APPLICATION_MODULES . $request->module . DS . $request->controller . '.php')) {
throw new Error404Exception($response);
}
require $file;
$controller = new $request->controller($response);
Logger::addPhpLog($request);
if (!method_exists($controller, $request->method)) {
throw new Error404Exception($response);
示例3: createServiceTranslator
/**
* Create service translator
*
* @return \Ixtrum\FileManager\Translator
*/
protected function createServiceTranslator()
{
$translator = new Translator();
return $translator->init($this->parameters["langDir"], $this->parameters["lang"]);
}
示例4: elseif
* config object and use the database information.
*/
#Connect to the DB && get configuration from database
$ferror = null;
if (!db_connect(DBHOST, DBUSER, DBPASS) || !db_select_database(DBNAME)) {
$ferror = 'Unable to connect to the database';
} elseif (!($cfg = Sys::getConfig())) {
$ferror = 'Unable to load config info from DB. Get tech support.';
}
if ($ferror) {
//Fatal error
Sys::alertAdmin('osTicket Fatal Error', $ferror);
//try alerting admin.
die("<b>Fatal Error:</b> Contact system adminstrator.");
//Generic error.
exit;
}
//Init
$cfg->init();
//Set default timezone...staff will overwrite it.
$_SESSION['TZ_OFFSET'] = $cfg->getTZoffset();
$_SESSION['daylight'] = $cfg->observeDaylightSaving();
#Cleanup magic quotes crap.
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$_POST = Format::strip_slashes($_POST);
$_GET = Format::strip_slashes($_GET);
$_REQUEST = Format::strip_slashes($_REQUEST);
}
$_SESSION['cfg'] = $cfg;
$trl =& Translator::init($cfg);
$_SESSION['trl'] =& $trl;
示例5: define
define('SYSTEM', ROOT . 'system/');
define('SCRIPT', ROOT . 'scripts/');
define('CACHE', ROOT . 'cache/');
define('APP', ROOT . 'app/');
define('CONFIG', APP . 'config/');
define('TRANSLATIONS', CONFIG . 'translations/');
define('CONTROLLER', APP . 'controllers/');
define('VIEW', APP . 'views/');
define('MODEL', APP . 'models/');
define('ASSETS', WEBROOT . 'assets/');
define('IMG', WEBROOT . 'assets/img/');
define('CSS', WEBROOT . 'assets/css/');
define('JS', WEBROOT . 'assets/js/');
require 'vendor/autoload.php';
require_once SYSTEM . 'config.php';
require_once SYSTEM . 'utils.php';
require_once SYSTEM . 'route.php';
require_once SYSTEM . 'router.php';
require_once SYSTEM . 'database.php';
require_once SYSTEM . 'translator.php';
require_once MODEL . 'session.php';
require_once CONFIG . 'app.php';
// ##### <TEMPORARY>
require_once MODEL . 'event_eggs.php';
// #### </TEMPORARY>
Database::connect();
Session::init();
$router = new Router();
$request = Utils::getPerformedRequest();
Translator::init($request);
$router->executeRequest($request);
示例6: init
/**
* Initialize the application.
*/
private function init()
{
$errorHandler = new ErrorHandler();
$errorHandler->register();
static::$DI = $DI = DI::instance();
$DI['Request'] = $request = new Http\Request();
$DI['Config'] = $config = new Config($this->sitePath, dirname($_SERVER['SCRIPT_FILENAME']), $request->getBaseUrl());
$DI['Alias'] = new Alias(['@app' => $config->get('app.path'), '@asset' => $this->sitePath . '/assets', '@media' => $config->get('media.path'), '@page' => $config->get('pages.path'), '@plugin' => $config->get('plugins.path'), '@post' => $config->get('posts.path'), '@site' => $this->sitePath, '@vendor' => $this->vendorDir, '@web' => $config->get('web.path')]);
$DI['Assets'] = function ($DI) {
return new Assets($DI['Alias'], $DI['Config']->get('web.url'));
};
$DI['Cache\\PageCache'] = function ($DI) {
return Cache\CacheFactory::create('page', $DI['Config']);
};
$DI['Cache\\DataCache'] = function ($DI) {
return Cache\CacheFactory::create('data', $DI['Config']);
};
$DI['DataArray'] = function ($DI) {
$loader = new Loader\DataLoader($DI['Config']->get('data.extensions'));
return $loader->load($DI['Config']->get('data.path'));
};
$DI['Loader\\PageLoader'] = function ($DI) {
$loader = new Loader\PageLoader($DI['Alias']);
return $loader;
};
$DI['Menu\\Page\\Builder'] = function ($DI) {
$paths = [];
$paths['@page'] = realpath($DI['Config']->get('pages.path'));
foreach ($DI['Config']->get('pages.extra_paths', []) as $alias) {
$paths[$alias] = $DI['Alias']->get($alias);
}
$extensions = $DI['Config']->get('pages.extensions', []);
$builder = new Menu\Page\Builder($paths, $extensions);
return $builder;
};
$DI['PluginManager'] = function ($DI) {
$enabled = $DI['Config']->get('plugins.enable', []);
$path = $DI['Config']->get('plugins.path');
$enabledSysPlugins = $DI['Config']->get('sysplugins.enable');
return new PluginManager($enabled, $path, $enabledSysPlugins);
};
$DI['Url\\UrlGenerator'] = function ($DI) {
return new Url\UrlGenerator($DI['Request'], $DI['Config']->get('nice_urls', false));
};
setlocale(LC_ALL, $DI['Config']->get('locale'));
// Add custom PSR-4 plugin path to Composer autoloader
$autoload = (require $this->vendorDir . '/autoload.php');
$autoload->addPsr4('herbie\\sysplugin\\', __DIR__ . '/../plugins/');
$autoload->addPsr4('herbie\\plugin\\', $DI['Config']->get('plugins.path'));
// Init PluginManager at first
if (true === $DI['PluginManager']->init($DI['Config'])) {
Hook::trigger(Hook::ACTION, 'pluginsInitialized', $DI['PluginManager']);
Hook::trigger(Hook::ACTION, 'shortcodeInitialized', $DI['Shortcode']);
$DI['Menu\\Page\\Collection'] = function ($DI) {
$DI['Menu\\Page\\Builder']->setCache($DI['Cache\\DataCache']);
return $DI['Menu\\Page\\Builder']->buildCollection();
};
$DI['Menu\\Page\\Node'] = function ($DI) {
return Menu\Page\Node::buildTree($DI['Menu\\Page\\Collection']);
};
$DI['Menu\\Page\\RootPath'] = function ($DI) {
$rootPath = new Menu\Page\RootPath($DI['Menu\\Page\\Collection'], $DI['Request']->getRoute());
return $rootPath;
};
$DI['Menu\\Post\\Collection'] = function ($DI) {
$builder = new Menu\Post\Builder($DI['Cache\\DataCache'], $DI['Config']);
return $builder->build();
};
$DI['Page'] = function ($DI) {
try {
$route = $DI['Request']->getRoute();
$page = false;
if (false === $page) {
$menuItem = $DI['Url\\UrlMatcher']->match($route);
$path = $menuItem->getPath();
$page = new Page();
$page->setLoader($DI['Loader\\PageLoader']);
$page->load($path);
Hook::trigger(Hook::ACTION, 'pageLoaded', $page);
}
} catch (\Exception $e) {
$page = new Page();
$page->layout = 'error.html';
$page->setError($e);
}
return $page;
};
$DI['Translator'] = function ($DI) {
$translator = new Translator($DI['Config']->get('language'), ['app' => $DI['Alias']->get('@app/../messages')]);
foreach ($DI['PluginManager']->getLoadedPlugins() as $key => $dir) {
$translator->addPath($key, $dir . '/messages');
}
$translator->init();
return $translator;
};
$DI['Url\\UrlMatcher'] = function ($DI) {
return new Url\UrlMatcher($DI['Menu\\Page\\Collection'], $DI['Menu\\Post\\Collection']);
//.........这里部分代码省略.........