本文整理汇总了PHP中I18n::setLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::setLanguage方法的具体用法?PHP I18n::setLanguage怎么用?PHP I18n::setLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::setLanguage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
I18n::setLanguage('');
Session::destroy();
if ($s = UserSession::get())
{
$s->delete();
}
Session::$site = 'http://www.test.info/';
Session::$referrer = 'http://www.test.info/some/part/of/the/site';
unlink(COORG_TEST_CONFIG);
copy(COORG_TEST_CONFIG_CLEAN, COORG_TEST_CONFIG);
$config = new Config(COORG_TEST_CONFIG);
$config->set('site/title', 'The Site');
$config->set('defaultLanguage', '');
CoOrg::init($config, 'app', 'plugins');
CoOrgSmarty::clearAll();
Header::$redirect = '__none__';
}
示例2: process
public static function process($request, $params = array(), $post = false)
{
self::$_resourceTheme = 'default';
include 'static/default/resources.coorg.php';
$theme = self::$_config->get('theme');
if (!$theme) $theme = 'default';
if ($theme != 'default')
{
self::$_resourceTheme = $theme;
if (file_exists('static/'.$theme.'/resources.coorg.php'))
{
include 'static/'.$theme.'/resources.coorg.php';
}
}
self::normalizeRequest($request);
$url = $request;
if ($request == '/' || $request == '') $request = 'home';
$requestParams = explode('/', $request);
$controllerName = ucfirst(array_shift($requestParams));
$prefix = null;
$requestWithoutPrefix = $request;
if (strlen($controllerName) == 2)
{
$prefix = strtolower($controllerName).'/';
I18n::setLanguage(strtolower($controllerName));
$requestWithoutPrefix = implode('/', $requestParams);
if (count($requestParams) > 0)
{
$controllerName = ucfirst(array_shift($requestParams));
}
else
{
$controllerName = 'Home';
}
}
else
{
$found = false;
//TODO: move Language DB to default install
// and unittest this... (in the CoOrg tests).
if (class_exists('Language'))
{
$preferredLanguages = Session::getPreferredLanguages();
$installedLanguages = Language::languageCodes(); // This is in the admin class, but should really be in the default instal
foreach ($preferredLanguages as $lc)
{
if (in_array($lc, $installedLanguages))
{
$found = true;
I18n::setLanguage($lc);
break;
}
else if (strpos($lc, '-'))
{
$slc = substr($lc, 0, strpos($lc, '-'));
if (in_array($slc, $installedLanguages))
{
$found = true;
I18n::setLanguage($slc);
break;
}
}
}
}
if (!$found && self::$_config->has('defaultLanguage'))
{
I18n::setLanguage(self::$_config->get('defaultLanguage'));
}
}
try
{
list($controllerClass, $action, $params, $request, $parentClasses) =
self::findController($controllerName, $requestParams,
$params, $post);
$controllerClass->coorgRequest = $requestWithoutPrefix;
$coorgUrl = self::config()->get('path').$prefix.$requestWithoutPrefix;
self::normalizeRequest($coorgUrl);
$controllerClass->coorgUrl = $coorgUrl;
$controllerClass->staticPath = self::$_config->get('path').'static/';
$controllerClass->coorgLanguage = self::getLanguage();
if (!$post && $controllerClass->isPost($action))
{
throw new WrongRequestMethodException();
}
if ($post && strpos(Session::getReferrer(), Session::getSite()) === false)
{
throw new WrongRequestMethodException();
}
self::$_request = $request;
self::$_requestParameters = $params;
$continue = true;
foreach ($parentClasses as $pClassName)
//.........这里部分代码省略.........
示例3: dirname
/**
* i18n.php
*
* Defines i18n l10n constants and initializes OPEN_LANGUAGE settings
*
* Licensed under the GNU GPL. For full terms see the file LICENSE.
*
* @package OpenClinic
* @copyright 2002-2013 jact
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @version CVS: $Id: i18n.php,v 1.4 2013/01/07 18:14:34 jact Exp $
* @author jact <jachavar@gmail.com>
* @since 0.7
*/
require_once dirname(__FILE__) . "/../lib/exe_protect.php";
executionProtection(__FILE__);
require_once "../lib/I18n.php";
$nls = I18n::getNLS();
if (!defined("OPEN_LANGUAGE")) {
define("OPEN_LANGUAGE", I18n::setLanguage());
} else {
I18n::setLanguage(OPEN_LANGUAGE);
}
define("OPEN_CHARSET", isset($nls['charset'][OPEN_LANGUAGE]) ? $nls['charset'][OPEN_LANGUAGE] : $nls['default']['charset']);
define("OPEN_DIRECTION", isset($nls['direction'][OPEN_LANGUAGE]) ? $nls['charset'][OPEN_LANGUAGE] : $nls['default']['direction']);
define("OPEN_ENCODING", isset($nls['encoding'][OPEN_LANGUAGE]) ? $nls['encoding'][OPEN_LANGUAGE] : $nls['default']['encoding']);
I18n::initLanguage(OPEN_LANGUAGE);
if (!defined("OPEN_TIME_ZONE")) {
define("OPEN_TIME_ZONE", "Europe/Madrid");
}
date_default_timezone_set(OPEN_TIME_ZONE);
示例4: testI18nManual
public function testI18nManual()
{
I18n::setLanguage('nl');
CoOrg::process('alpha/sub/i18ntest');
$this->assertEquals('Google is leuk', AlphaSubController::$i18ntest1);
$this->assertEquals('shit van Google', AlphaSubController::$i18ntest2);
$this->assertEquals('Dit bericht komt van alpha', AlphaSubController::$i18nfromAlpha);
$this->assertEquals('Message not found with 1 paramaters', AlphaSubController::$notFoundWithParams);
AlphaSubController::$i18ntest1 = '';
AlphaSubController::$i18ntest2 = '';
AlphaSubController::$i18nfromAlpha = '';
AlphaSubController::$notFoundWithParams = '';
}