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


PHP I18n::setLanguage方法代码示例

本文整理汇总了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__';
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:20,代码来源:coorg.test.class.php

示例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)
//.........这里部分代码省略.........
开发者ID:nathansamson,项目名称:CoOrg,代码行数:101,代码来源:coorg.class.php

示例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);
开发者ID:edubort,项目名称:openclinic-1,代码行数:31,代码来源:i18n.php

示例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 = '';
	}
开发者ID:nathansamson,项目名称:CoOrg,代码行数:15,代码来源:coorg.Test.php


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