本文整理汇总了PHP中Localize类的典型用法代码示例。如果您正苦于以下问题:PHP Localize类的具体用法?PHP Localize怎么用?PHP Localize使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Localize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateData
function validateData()
{
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, 'admin');
$valid = true;
if (!is_numeric($this->_sessionTimeout)) {
$valid = false;
$this->_sessionTimeoutError = $loc->getText("Session timeout must be numeric.");
} elseif ($this->_sessionTimeout <= 0) {
$valid = false;
$this->_sessionTimeoutError = $loc->getText("Session timeout must be greater than 0.");
}
if (!is_numeric($this->_itemsPerPage)) {
$valid = false;
$this->_itemsPerPageError = $loc->getText("Items per page must be numeric.");
} elseif ($this->_itemsPerPage <= 0) {
$valid = false;
$this->_itemsPerPageError = $loc->getText("Items per page must be greater than 0.");
}
if (!is_numeric($this->_purgeHistoryAfterMonths)) {
$valid = false;
$this->_purgeHistoryAfterMonthsError = $loc->getText("Months must be numeric.");
}
if (!is_numeric($this->_inactiveMemberAfterDays)) {
$valid = false;
$this->_inactiveMemberAfterDaysError = $loc->getText("Days must be numeric.");
}
return $valid;
}
示例2: T
function T($msg, $vars = NULL)
{
# Kludge to adapt 1.0-pre code to 0.6
static $loc = NULL;
if ($loc == NULL) {
$loc = new Localize(OBIB_LOCALE, 'classes');
}
return $loc->getText($msg, $vars);
}
示例3: getMessages
/**
* getter for messages
*
* @param int $room
* @param int $user
* @param int $time
* @param int $game
* @return array
*/
public static function getMessages($room, $toUser = 0, $time = 0, $game = 0)
{
$colorRepository = new ColorRepository(TRUE);
$colors = $colorRepository->getAll();
$colorList = array();
foreach ($colors as $color) {
$colorList[$color['id']] = $color;
}
$query = 'SELECT user.*, message.*
FROM ' . DB_PREFIX . self::$table . ' AS message
LEFT JOIN ' . DB_PREFIX . 'user AS user ON message.user = user.id
WHERE room=' . intval($room) . ' AND tstamp > ' . intval($time) . '
AND to_user IN (' . intval($toUser) . ', 0)';
if ($game) {
$query .= ' AND game=' . intval($game);
}
if ($toUser) {
$query .= ' AND NOT not_to_user IN (' . $toUser . ')';
}
$query .= ' ORDER BY message.id DESC LIMIT 100';
$messages = DB::fetchAll($query);
$messages = array_reverse($messages);
foreach ($messages as &$message) {
if ($message['localize_key']) {
$message['text'] = Localize::getMessage($message['localize_key'], unserialize($message['localize_params']));
}
$message['color'] = $colorList[$message['color']]['code'];
}
return $messages;
}
示例4: error_handler
/**
* @param $errno
* @param $errstr
* @param $errfile
* @param $errline
* @param $errcontext
*/
static function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
$default_domain = Localize::textDomain(NULL);
Localize::textDomain(self::$domain);
$format = "[%s] %s %s(%s)\n";
$lang_sub_list = array(__gt("array"), __gt("string"), __gt("object"));
$lang_list = array(__gt('Missing argument %d for %s, called in'), __gt('Use of undefined constant %s - assumed \'%s\''), __gt('%s to %s conversion'), __gt('Illegal string offset \'%s\''), __gt('Call to undefined method'), __gt('Non-static method %s should not be called statically'), __gt('Call to protected method %s from context \'%s\''), __gt('Cannot access private property'), __gt('Undefined variable: %s'), __gt('Undefined index: %s'), __gt('Illegal offset type in isset or empty'), __gt('%s expects parameter %s to be %s, %s given'), __gt('Call to private method %s from context \'%s\''), __gt('Call to a member function %s on a non-object'), __gt('Invalid argument supplied for %s'));
$errorno_str = array(E_ERROR => 'ERROR', E_WARNING => 'WARNING', E_PARSE => 'PARSE', E_NOTICE => 'NOTICE', E_CORE_ERROR => 'CORE_ERROR', E_CORE_WARNING => 'CORE_WARNING', E_COMPILE_ERROR => 'COMPILE_ERROR', E_COMPILE_WARNING => 'COMPILE_WARNING', E_USER_ERROR => 'USER_ERROR', E_USER_WARNING => 'USER_WARNING', E_USER_NOTICE => 'USER_NOTICE', E_STRICT => 'STRICT', E_RECOVERABLE_ERROR => 'RECOVERABLE_ERROR', E_DEPRECATED => 'DEPRECATED', E_USER_DEPRECATED => 'USER_DEPRECATED');
$errorno_list = array(E_ERROR => __('Fatal run-time errors'), E_WARNING => __('Run-time warnings (non-fatal errors)'), E_PARSE => __('Compile-time parse errors'), E_NOTICE => __('Run-time notices'), E_CORE_ERROR => __('Fatal errors that occur during PHP\'s initial startup'), E_CORE_WARNING => __('Warnings (non-fatal errors)'), E_COMPILE_ERROR => __('Fatal compile-time errors'), E_COMPILE_WARNING => __('Compile-time warnings (non-fatal errors)'), E_USER_ERROR => __('User-generated error message'), E_USER_WARNING => __('User-generated warning message'), E_USER_NOTICE => __('User-generated notice message'), E_STRICT => __('Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code'), E_RECOVERABLE_ERROR => __('Catchable fatal error'), E_DEPRECATED => __('Run-time notices'), E_USER_DEPRECATED => __('User-generated warning message'));
$errno_lg = "";
if (isset($errorno_list[$errno])) {
$errno_lg = $errorno_list[$errno];
}
$errno = $errorno_str[$errno] . ":" . $errno_lg;
foreach ($lang_list as $v) {
$pv0 = self::get_pregstr($v[0]);
if (preg_match("/" . $pv0 . "/", $errstr, $mt)) {
$pv1 = self::get_pregstr_replace($v[1]);
$errstr = preg_replace("/" . $pv0 . "/", $pv1, $errstr, 1);
foreach ($lang_sub_list as $vv) {
$pvv0 = self::get_pregstr($vv[0]);
$pvv1 = self::get_pregstr_replace($vv[1]);
$errstr = preg_replace("/([\\b])" . $pvv0 . "([\\b])/i", "\$1" . $pvv1 . "\$2", $errstr);
}
break;
}
}
echo sprintf($format, $errno, $errstr, $errfile, $errline, $errcontext);
Localize::textDomain($default_domain);
}
示例5: addLocalizeToLocs
function addLocalizeToLocs($locs, $page)
{
$localizes = Localize::where('`page` = "' . $page . '"', ['title', self::get_loc()]);
foreach ($localizes as $loc) {
$locs['localize_' . $loc->title] = $loc->{self::get_loc()};
}
return $locs;
}
示例6: smarty_function_localize
/**
* Smarty {localize} function plugin
*
*/
function smarty_function_localize($params, &$smarty)
{
$attrs = array();
if ($params['attrs']) {
$attrs = explode('###', $params['attrs']);
}
return Localize::getMessage($params['key'], $attrs);
}
示例7: validateData
function validateData()
{
$loc = new Localize(OBIB_LOCALE, "classes");
$valid = true;
if ($this->_isRequired and $this->_fieldData == "") {
$valid = false;
$this->_fieldDataError = $loc->getText("biblioFieldError1");
}
if ($this->_tag == "") {
$valid = false;
$this->_tagError = $loc->getText("biblioFieldError1");
} else {
if (!is_numeric($this->_tag)) {
$valid = false;
$this->_tagError = $loc->getText("biblioFieldError2");
}
}
if ($this->_subfieldCd == "") {
$valid = false;
$this->_subfieldCdError = $loc->getText("biblioFieldError1");
}
// Check for image
if ($this->getTag() == "902" && $this->getSubfieldCd() == "a") {
$fieldData = $this->getFieldData();
$index = $this->getTag() . $this->getSubfieldCd();
if (!empty($fieldData["tmp_name"][$index])) {
if ($info = getimagesize($fieldData["tmp_name"][$index])) {
$filename = $fieldData["name"][$index];
$filename_parts = explode(".", $filename);
unset($filename_parts[count($filename_parts) - 1]);
$filename = implode("-", $filename_parts);
$allow_types = array('image/jpeg', 'image/png', 'image/gif');
// If file type is allowed
if (in_array($info["mime"], $allow_types)) {
$ext = image_type_to_extension($info[2]);
$tmp = md5($filename . session_id() . time());
$filename = $filename . "_" . substr($tmp, strlen($tmp) - 7, strlen($tmp)) . $ext;
$filepath = "../pictures/{$filename}";
copy($fieldData["tmp_name"][$index], $filepath);
make_thumbnail($filepath, array('width' => 200));
$this->setFieldData($filename);
} else {
$valid = false;
$this->_fieldDataError = $loc->getText("biblioFieldErrorPictureType");
}
} else {
$valid = false;
$this->_fieldDataError = $loc->getText("biblioFieldErrorPictureType");
}
}
}
unset($loc);
return $valid;
}
示例8: setLocale
/**
* Set locale of output data
*
* @param string $locale Name of locale, the same format of setlocale php function
*
* @return Localize Current instance of that class, for chaining methods
*/
public static function setLocale($locale)
{
$locales = array($locale . '.utf-8', $locale . '.UTF-8', $locale);
$os = strtolower(php_uname('s'));
if (strpos($os, 'windows') !== false) {
$locales = array(Formats::$windowsLocaleMap[$locale]);
}
if (!setlocale(LC_ALL, $locales)) {
throw new LocaleException("Locale {$locale} não disponível no seu sistema.");
}
self::$currentLocale = $locale;
return new static();
}
示例9: setup
protected function setup()
{
$loggedUser = LoggedUser::whoIsLogged();
if (Utils::post('create_room') && $loggedUser['admin']) {
$params = array('title' => Utils::post('title'), 'alias' => Utils::createAlias(Utils::post('title'), 'room'), 'description' => Utils::post('description'));
$room = new Room($params);
$room->save();
}
$roomRepository = new RoomRepository();
$rooms = $roomRepository->getAll();
$gameRepository = new GameRepository();
$games = $gameRepository->getGamesByRooms(array_keys($rooms));
foreach ($games as $game) {
$rooms[$game['room']]['game'] = TRUE;
$rooms[$game['room']]['status'] = Localize::getMessage('room_status_' . $game['status']);
}
MySmarty::assign('loggedUser', $loggedUser);
MySmarty::assign('rooms', $rooms);
}
示例10: setup
protected function setup()
{
$loggedUser = LoggedUser::whoIsLogged();
MySmarty::assign('loggedUser', $loggedUser);
MySmarty::assign('room', $this->room);
if ($this->game) {
MySmarty::assign('game', $this->game);
MySmarty::assign('gameStartedStatus', Game::GAME_STATUS_STARTED);
$playerRepository = new PlayerRepository();
$actualPlayer = $playerRepository->getOneByGameAndUser($this->game['id'], $loggedUser['id']);
// phases when we want to make autoreload
$refreshGameBox = FALSE;
if (in_array($actualPlayer['phase'], array(Player::PHASE_NONE, Player::PHASE_WAITING))) {
if ($this->game['status'] == Game::GAME_STATUS_INITIALIZED && $actualPlayer['possible_choices'] != '') {
$refreshGameBox = FALSE;
} else {
$refreshGameBox = TRUE;
}
}
MySmarty::assign('refreshGameBox', $refreshGameBox);
// zobrazime len hracovi ktory je na tahu resp. v medzitahu
$playerOnMove = $this->game->getPlayerOnMove();
if ($playerOnMove['id'] == $actualPlayer['id'] || $this->game['status'] == Game::GAME_STATUS_INITIALIZED) {
MySmarty::assign('response', $actualPlayer['command_response']);
}
if ($this->game['status'] == Game::GAME_STATUS_CREATED) {
if (!GameUtils::checkUserInGame($loggedUser, $this->game)) {
MySmarty::assign('joinGameAvailable', TRUE);
} elseif ($loggedUser['id'] == $this->game['creator']) {
MySmarty::assign('startGameAvailable', Localize::getMessage('start_game'));
}
} elseif ($this->game['status'] == Game::GAME_STATUS_ENDED) {
MySmarty::assign('createGameAvailable', Localize::getMessage('create_game'));
MySmarty::assign('refreshGameBox', TRUE);
}
} else {
MySmarty::assign('createGameAvailable', Localize::getMessage('create_game'));
MySmarty::assign('refreshGameBox', TRUE);
}
}
示例11: input
/**
* Sobrecarga do método input incluindo funcionalidades
* extras, tais como:
*
* 1 - Localização automática dos tipos date/datetime e numérico/float
* 2 - Formatação baseada no TwitterBootstrap
*
*/
public function input($fieldName, $options = array())
{
$this->setEntity($fieldName);
$modelKey = $this->model();
$fieldKey = $this->field();
$fieldDef = $this->_introspectModel($modelKey, 'fields', $fieldKey);
$value = null;
if (isset($options['value'])) {
$value = $options['value'];
} else {
if (isset($this->request->data[$modelKey][$fieldKey])) {
$value = $this->request->data[$modelKey][$fieldKey];
}
}
if ((!isset($options['localize']) || $options['localize'] === true) && !empty($value)) {
switch ($fieldDef['type']) {
case 'date':
$value = Localize::date($value);
break;
case 'datetime':
case 'timestamp':
$value = Localize::datetime($value);
break;
case 'float':
$value = Localize::number($value);
break;
}
$options['value'] = $value;
}
if ((!isset($options['keepSeconds']) || $options['keepSeconds'] === true) && $fieldDef['type'] === 'time') {
$options['value'] = empty($value) || !preg_match('/[0-9]{2}\\:[0-9]{2}(\\:[0-9]{2})?/') ? '00:00' : substr($value, 0, 5);
}
if (!isset($options['useBootstrap']) || $options['useBootstrap'] === true) {
/**
* @todo Helper não deve estender o BootstrapForm, mas
* sim usa-lo quando definido.
*/
}
return parent::input($fieldName, $options);
}
示例12: validateData
function validateData()
{
$loc = new Localize(OBIB_LOCALE, "classes");
$valid = true;
if ($this->_isRequired and $this->_fieldData == "") {
$valid = false;
$this->_fieldDataError = $loc->getText("biblioFieldError1");
}
if ($this->_tag == "") {
$valid = false;
$this->_tagError = $loc->getText("biblioFieldError1");
} else {
if (!is_numeric($this->_tag)) {
$valid = false;
$this->_tagError = $loc->getText("biblioFieldError2");
}
}
if ($this->_subfieldCd == "") {
$valid = false;
$this->_subfieldCdError = $loc->getText("biblioFieldError1");
}
unset($loc);
return $valid;
}
示例13: Localize
<?php
/* This file is part of a copyrighted work; it is distributed with NO WARRANTY.
* See the file COPYRIGHT.html for more details.
*/
require_once "../shared/common.php";
$tab = "home";
$nav = "home";
require_once "../shared/header.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
?>
<h1><?php
echo $loc->getText("indexHeading");
?>
</h1>
<?php
# echo $loc->getText("searchResults",array("items"=>0))."<br>";
?>
<?php
echo $loc->getText("indexIntro");
?>
<br><br>
<table class="primary">
<tr>
<th><?php
echo $loc->getText("indexTab");
?>
示例14: Localize
<?php
/* This file is part of a copyrighted work; it is distributed with NO WARRANTY.
* See the file COPYRIGHT.html for more details.
*/
require_once "../shared/common.php";
$tab = "admin";
$nav = "themes";
require_once "../shared/logincheck.php";
require_once "../classes/Localize.php";
$loc = new Localize(OBIB_LOCALE, $tab);
#****************************************************************************
#* Checking for query string. Go back to theme list if none found.
#****************************************************************************
if (!isset($_GET["themeid"])) {
header("Location: ../admin/theme_list.php");
exit;
}
$themeid = $_GET["themeid"];
$name = $_GET["name"];
#**************************************************************************
#* Show confirm page
#**************************************************************************
require_once "../shared/header.php";
?>
<center>
<form name="delstaffform" method="POST" action="../admin/theme_del.php?themeid=<?php
echo HURL($themeid);
?>
&name=<?php
echo HURL($name);
示例15: REL
<script language="JavaScript1.1" >
/* This file is part of a copyrighted work; it is distributed with NO WARRANTY.
* See the file COPYRIGHT.html for more details.
*/
// JavaScript Document
//------------------------------------------------------------------------------
// lookup Javascript
lkup = {
<?php
require_once REL(__FILE__, "../classes/Localize.php");
$jsLoc = new Localize(OBIB_LOCALE, $tab);
echo "z3950Search\t\t\t\t:'" . $jsLoc->getText("lookup_z3950Search") . "',\n";
echo "isbn\t\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_isbn") . "',\n";
echo "issn\t\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_issn") . "',\n";
echo "lccn\t\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_lccn") . "',\n";
echo "title\t\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_title") . "',\n";
echo "author\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_author") . "',\n";
echo "keyword\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_keyword") . "',\n";
echo "publisher\t\t\t\t\t:'" . $jsLoc->getText("lookup_publisher") . "',\n";
echo "pubLoc\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_pubLoc") . "',\n";
echo "pubDate\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_pubDate") . "',\n";
echo "andOpt\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_andOpt") . "',\n";
echo "search\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_search") . "',\n";
echo "abandon\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_abandon") . "',\n";
echo "repository\t\t\t\t:'" . $jsLoc->getText("lookup_repository") . "',\n";
echo "yaz_setup_failed\t:'" . $jsLoc->getText("lookup_yazSetupFailed") . "',\n";
echo "badQuery\t\t\t\t\t:'" . $jsLoc->getText("lookup_badQuery") . "',\n";
echo "patience\t\t\t\t\t:'" . $jsLoc->getText("lookup_patience") . "',\n";
echo "resetInstr\t\t\t\t:'" . $jsLoc->getText("lookup_resetInstr") . "',\n";
echo "goBack\t\t\t\t\t\t:'" . $jsLoc->getText("lookup_goBack") . "',\n";