本文整理汇总了PHP中I18n::getNLS方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::getNLS方法的具体用法?PHP I18n::getNLS怎么用?PHP I18n::getNLS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::getNLS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLanguage
/**
* string setLanguage(string $lang = "")
*
* Sets a language to locale options
*
* @param string $lang (optional)
* @return string new language setted
* @access public
* @static
* @see OPEN_LANG_DEFAULT
*/
public static function setLanguage($lang = "")
{
$newLang = OPEN_LANG_DEFAULT;
if (empty($lang)) {
// Detect Browser Language
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
$language = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
$langPieces = explode("-", $language[0]);
if (strlen($language[0]) == 2) {
$browserLanguage = $language[0] . "_" . strtoupper($language[0]);
} else {
$browserLanguage = strtolower($langPieces[0]) . "_" . strtoupper($langPieces[1]);
}
if (self::languageExists($browserLanguage)) {
$newLang = $browserLanguage;
}
}
} else {
if (self::languageExists($lang)) {
$newLang = $lang;
}
}
putenv("LANG=" . $newLang);
//setlocale(LC_ALL, $newLang);
$nls = I18n::getNLS();
if (defined("PHP_OS") && preg_match("/win/i", PHP_OS)) {
setlocale(LC_ALL, isset($nls['win32'][$newLang]) ? $nls['win32'][$newLang] : $newLang);
} else {
setlocale(LC_ALL, $newLang);
}
return $newLang;
}
示例2: 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);