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


PHP Locale::initialize方法代码示例

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


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

示例1: execute

 /**
  * Create the test locale file.
  */
 function execute()
 {
     Locale::initialize();
     $localeFiles =& Locale::getLocaleFiles();
     $localeFile = array_shift($localeFiles[$this->inLocale]);
     $localeData = LocaleFile::load($localeFile->filename);
     if (!isset($localeData)) {
         printf('Invalid locale \'%s\'', $this->inLocale);
         exit(1);
     }
     $outFile = sprintf('locale/%s/locale.xml', $this->outLocale);
     $fp = fopen($outFile, 'wb');
     if (!$fp) {
         printf('Failed to write to \'%s\'', $outFile);
         exit(1);
     }
     fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE locale SYSTEM \"../locale.dtd\">\n\n" . "<!--\n" . "  * locale.xml\n" . "  *\n" . "  * Copyright (c) 2003-2007 John Willinsky\n" . "  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.\n" . "  *\n" . sprintf("  * Localization strings for the %s (%s) locale.\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME) . "  *\n" . "  * \$Id\$\n" . "  -->\n\n" . sprintf("<locale name=\"%s\" full_name=\"%s\">\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME));
     foreach ($localeData as $key => $message) {
         $outMessage = $this->fancifyString($message);
         if (strstr($outMessage, '<') || strstr($outMessage, '>')) {
             $outMessage = '<![CDATA[' . $outMessage . ']]>';
         }
         fwrite($fp, sprintf("\t<message key=\"%s\">%s</message>\n", $key, $outMessage));
     }
     fwrite($fp, "</locale>\n");
     fclose($fp);
 }
开发者ID:alenoosh,项目名称:ojs,代码行数:30,代码来源:genTestLocale.php

示例2: execute

 /**
  * Create the test locale file.
  */
 function execute()
 {
     Locale::initialize();
     $localeFiles = Locale::makeComponentMap($this->inLocale);
     foreach ($localeFiles as $localeFilePath) {
         $localeFile = basename($localeFilePath);
         $outFile = dirname(dirname($localeFilePath)) . '/' . $this->outLocale . '/' . $localeFile;
         $this->generateLocaleFile($localeFile, $localeFilePath, $outFile);
     }
 }
开发者ID:ramonsodoma,项目名称:ocs,代码行数:13,代码来源:genTestLocale.php

示例3: CommandLineTool

 function CommandLineTool($argv = array())
 {
     // Initialize the a request object with a page router
     $application =& PKPApplication::getApplication();
     $request =& $application->getRequest();
     // FIXME: Write and use a CLIRouter here (see classdoc)
     import('classes.core.PageRouter');
     $router = new PageRouter();
     $router->setApplication($application);
     $request->setRouter($router);
     // Initialize the locale and load generic plugins.
     Locale::initialize();
     PluginRegistry::loadCategory('generic');
     $this->argv = isset($argv) && is_array($argv) ? $argv : array();
     if (isset($_SERVER['SERVER_NAME'])) {
         die('This script can only be executed from the command-line');
     }
     $this->scriptName = isset($this->argv[0]) ? array_shift($this->argv) : '';
     if (isset($this->argv[0]) && $this->argv[0] == '-h') {
         $this->usage();
         exit(0);
     }
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:23,代码来源:CliTool.inc.php

示例4: dispatch

 /**
  * Determine the correct router for this request. Then
  * let the router dispatch the request to the appropriate
  * handler method.
  * @param $request PKPRequest
  */
 function dispatch(&$request)
 {
     // Make sure that we have at least one router configured
     $routerNames = $this->getRouterNames();
     assert(count($routerNames) > 0);
     // Go through all configured routers by priority
     // and find out whether one supports the incoming request
     foreach ($routerNames as $shortcut => $routerCandidateName) {
         $routerCandidate =& $this->_instantiateRouter($routerCandidateName, $shortcut);
         // Does this router support the current request?
         if ($routerCandidate->supports($request)) {
             // Inject router into request
             $request->setRouter($routerCandidate);
             $router =& $routerCandidate;
             $this->_router =& $router;
             // We've found our router and can go on
             // to handle the request.
             break;
         }
     }
     // None of the router handles this request? This is a development-time
     // configuration error.
     if (is_null($router)) {
         fatalError('None of the configured routers supports this request.');
     }
     // Can we serve a cached response?
     if ($router->isCacheable($request)) {
         if (Config::getVar('cache', 'web_cache')) {
             if ($this->_displayCached($router, $request)) {
                 exit;
             }
             // Success
             ob_start(array(&$this, '_cacheContent'));
         }
     } else {
         if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') {
             header('HTTP/1.0 403 Forbidden');
             echo '403: Forbidden<br><br>Pre-fetching not allowed.';
             exit;
         }
     }
     Locale::initialize();
     PluginRegistry::loadCategory('generic');
     $router->route($request);
 }
开发者ID:anorton,项目名称:pkp-lib,代码行数:51,代码来源:Dispatcher.inc.php

示例5: dirname

if (basename($_SERVER['SCRIPT_FILENAME'], ".php") == "rfiles") {
    $baseDir = dirname($baseDir);
}
define('INDEX_FILE_LOCATION', $baseDir . '/index.php');
// Load and execute initialization code
chdir($baseDir);
require $baseDir . '/lib/pkp/includes/bootstrap.inc.php';
// Manually set up a context router to get access
// to the application context (required by Locale).
$application =& PKPApplication::getApplication();
$request =& $application->getRequest();
import('core.PKPRouter');
$router = new PKPRouter();
$router->setApplication($application);
$request->setRouter($router);
Locale::initialize();
// Load user variables
$sessionManager =& SessionManager::getManager();
$userSession =& $sessionManager->getUserSession();
$user =& $userSession->getUser();
// Insert system variables into associative array to be used by iBrowser
$init['publicDir'] = Config::getVar('files', 'public_files_dir');
if (isset($user)) {
    // User is logged in
    $init['user'] = $user->getUsername();
    //$init['lang'] = String::substr(Locale::getLocale(), 0, 2);
    $init['lang'] = 'en';
    $init['baseUrl'] = Config::getVar('general', 'base_url');
    $init['baseDir'] = $baseDir;
    $application = PKPApplication::getApplication();
    $contextDepth = $application->getContextDepth();
开发者ID:alexukua,项目名称:j2test,代码行数:31,代码来源:Init.inc.php


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