本文整理汇总了PHP中Lang::translate方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::translate方法的具体用法?PHP Lang::translate怎么用?PHP Lang::translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lang
的用法示例。
在下文中一共展示了Lang::translate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process a template (catch displayed content)
*
* @param string $id template id
* @param array $vars template variables
*
* @return string parsed template content
*/
public static function process($id, $vars = array())
{
// Are we asked to not output context related html comments ?
$addctx = true;
if (substr($id, 0, 1) == '!') {
$addctx = false;
$id = substr($id, 1);
}
// Resolve template file path
$path = self::resolve($id);
return (new Event('template_process', $id, $path, $vars, $addctx))->trigger(function ($id, $path, $vars, $addctx) {
// Lambda renderer to isolate context
$renderer = function ($_path, $_vars) {
foreach ($_vars as $_k => $_v) {
if (substr($_k, 0, 1) != '_') {
${$_k} = $_v;
}
}
include $_path;
};
// Render
$exception = null;
ob_start();
try {
$renderer($path, $vars);
} catch (Exception $e) {
$exception = $e;
}
$content = ob_get_clean();
// Translation syntax
$content = preg_replace_callback('`\\{(loc|tr|translate):([^}]+)\\}`', function ($m) {
return (string) Lang::translate($m[2]);
}, $content);
// Config syntax
$content = preg_replace_callback('`\\{(cfg|conf|config):([^}]+)\\}`', function ($m) {
return Config::get($m[2]);
}, $content);
// Image syntax
$content = preg_replace_callback('`\\{(img|image):([^}]+)\\}`', function ($m) {
return GUI::path('images/' . $m[2]);
}, $content);
// Path syntax
$content = preg_replace_callback('`\\{(path):([^}]*)\\}`', function ($m) {
return GUI::path($m[2]);
}, $content);
// URL syntax
$content = preg_replace_callback('`\\{(url):([^}]*)\\}`', function ($m) {
return preg_replace('`^(https?://)?([^/]+)/`', '/', Config::get('application_url')) . $m[2];
}, $content);
// Add context as a html comment if required
if ($addctx) {
$content = "\n" . '<!-- template:' . $id . ' start -->' . "\n" . $content . "\n" . '<!-- template:' . $id . ' end -->' . "\n";
}
// If rendering threw rethrow
if ($exception) {
throw $exception;
}
return $content;
});
}
示例2: blacklistAction
public function blacklistAction()
{
$model = new FriendsModel();
Pagination::calculate(get('page', 'int'), 15, $model->countFriends(Request::getParam('user')->id, 'out', 0, 1, false));
$this->view->blacklist = $model->getFriends(Request::getParam('user')->id, 'out', 0, 1, false, Pagination::$start, Pagination::$end);
$this->view->title = Lang::translate('BLACKLIST_TITLE');
}
示例3: getCredentials
/**
* Generates Rackspace API key credentials
* {@inheritDoc}
*/
public function getCredentials()
{
$secret = $this->getSecret();
if (!empty($secret['username']) && !empty($secret['apiKey'])) {
$credentials = array('auth' => array('RAX-KSKEY:apiKeyCredentials' => array('username' => $secret['username'], 'apiKey' => $secret['apiKey'])));
if (!empty($secret['tenantName'])) {
$credentials['auth']['tenantName'] = $secret['tenantName'];
} elseif (!empty($secret['tenantId'])) {
$credentials['auth']['tenantId'] = $secret['tenantId'];
}
return json_encode($credentials);
} else {
throw new Exceptions\CredentialError(Lang::translate('Unrecognized credential secret'));
}
}
示例4: view
public function view()
{
$strings = $_GET['strings'];
$namespace = empty($_GET['namespace']) ? null : General::sanitize($_GET['namespace']);
$new = array();
foreach ($strings as $key => $value) {
// Check value
if (empty($value) || ($value = 'false')) {
$value = $key;
}
$value = General::sanitize($value);
// Translate
$new[$value] = Lang::translate(urldecode($value), null, $namespace);
}
$this->_Result = $new;
}
示例5: setArray
/**
* Sets metadata values from an array, with optional prefix
*
* If $prefix is provided, then only array keys that match the prefix
* are set as metadata values, and $prefix is stripped from the key name.
*
* @param array $values an array of key/value pairs to set
* @param string $prefix if provided, a prefix that is used to identify
* metadata values. For example, you can set values from headers
* for a Container by using $prefix='X-Container-Meta-'.
* @return void
*/
public function setArray($values, $prefix = null)
{
if (empty($values)) {
return false;
}
foreach ($values as $key => $value) {
if ($prefix) {
if (strpos($key, $prefix) === 0) {
$name = substr($key, strlen($prefix));
$this->getLogger()->info(Lang::translate('Setting [{name}] to [{value}]'), array('name' => $name, 'value' => $value));
$this->{$name} = $value;
}
} else {
$this->{$key} = $value;
}
}
}
示例6: SetArray
/**
* Sets metadata values from an array, with optional prefix
*
* If $prefix is provided, then only array keys that match the prefix
* are set as metadata values, and $prefix is stripped from the key name.
*
* @param array $values an array of key/value pairs to set
* @param string $prefix if provided, a prefix that is used to identify
* metadata values. For example, you can set values from headers
* for a Container by using $prefix='X-Container-Meta-'.
* @return void
*/
public function SetArray($values, $prefix = null)
{
if (empty($values)) {
return false;
}
foreach ($values as $key => $value) {
if ($prefix) {
if (strpos($key, $prefix) === 0) {
$name = substr($key, strlen($prefix));
$this->debug(Lang::translate('Setting [%s] to [%s]'), $name, $value);
$this->{$name} = $value;
}
} else {
$this->{$key} = $value;
}
}
}
示例7: indexAction
public function indexAction()
{
$model = new ChatModel();
setSession('chat_ses', 0);
$this->view->list = $model->getChatMessages('chat');
$this->view->title = Lang::translate('INDEX_TITLE');
$this->view->onlines = $model->getUserOnline();
/* $countUser = 0;
while ($list = mysqli_fetch_object($listUserOnline)) {
$userList .= '<li><a href="' . url($list->id) . '" target="_blank"><span>' . $list->nickname . '</span><span class="level-icon">' . $list->level . '</span></a></li>';
$countUser++;
} */
}
示例8: getCookie
<div class="box">
<?php
if (getCookie('error')) {
echo getCookie('error');
}
?>
<?php
if ($this->msg) {
echo $this->msg;
echo '<br/><a href="' . url('page', 'recovery') . '">' . Lang::translate("RECOVERY_GO_BACK") . '</a>';
} else {
?>
<form action="<?php
echo url('page', 'recovery');
?>
" method="POST">
<div class="formRow">
<div class="formRowTitle">
{L:RECOVERY_EMAIL}
</div>
<div class="formRowField">
<input type="email" name="email" value="<?php
echo post('email') ? post('email') : '';
?>
" required="required" />
</div>
</div>
<div class="formRow">
示例9: banAction
public function banAction()
{
//$model = new ProfileModel();
$this->view->title = Lang::translate('BAN_TITLE');
}
示例10: userstatAction
public function userstatAction()
{
$model = new AdminModel();
$this->view->count = $model->countUsers();
$this->view->count24h = $model->countUsers("`dateLast` > '" . (time() - 24 * 3600) . "'");
$this->view->list = $model->getUsersOnline();
$this->view->title = Lang::translate('USERSTAT_TITLE');
}
示例11:
<h1>{L:INDEX_TITLE}</h1>
<div><a class="marker-icon" href="{URL:admin/news}">{L:INDEX_NEWS}</a></div>
<div><a href="{URL:admin/verify_users}"><?php
echo Lang::translate('INDEX_VERIFY_USERS') . ' (' . $this->countVerifyUsers . ')';
?>
</a></div>
<div><a href="{URL:admin/disputes}">{L:INDEX_DISPUTES}</a></div>
<div><a href="{URL:admin/servers}">{L:INDEX_SERVERS}</a></div>
<div><a class="marker-icon" href="{URL:admin/users}">{L:INDEX_USERS}</a></div>
<div><a class="marker-icon" href="{URL:admin/userstat}">{L:INDEX_USERS_STAT}</a></div>
<div><a class="marker-icon" href="{URL:admin/guests}">{L:INDEX_GUESTS}</a></div>
示例12: social_saveAction
public function social_saveAction()
{
if (empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
error404();
}
$model = new SettingsModel();
$save['facebook'] = post('__facebook');
$save['steam'] = post('__steam');
$save['twitch'] = post('__twitch');
$save['twitter'] = post('__twitter');
$save['youtube'] = post('__youtube');
$model->setSettings(Request::getParam('user')->id, $save);
$status = '<div class="">' . Lang::translate('SOCIAL_SAVED') . '</div>';
$response['error'] = 0;
$response['target_h']['#status'] = $status;
echo json_encode($response);
exit;
}
示例13: resourceName
/**
* Returns the resource name for the URL of the object; must be overridden
* in child classes
*
* For example, a server is `/servers/`, a database instance is
* `/instances/`. Must be overridden in child classes.
*
* @throws UrlError
*/
public static function resourceName()
{
if (isset(static::$url_resource)) {
return static::$url_resource;
}
throw new Exceptions\UrlError(sprintf(Lang::translate('No URL resource defined for class [%s] in ResourceName()'), get_class()));
}
示例14: while
<h1>{L:INDEX_VERIFY_USERS}</h1>
<?php
while ($list = mysqli_fetch_object($this->list)) {
echo '<div>';
echo '<a href="' . url($list->id) . '">' . $list->nickname . '</a>';
echo ' <span id="verify' . $list->id . '">(';
echo '<a onclick="' . ajaxLoad(url('admin', 'verify_users_submit'), 'verifys', 'id:' . $list->id) . '">' . Lang::translate('VERIFY_USERS_SUBMIT') . '</a> | ';
echo '<a onclick="' . ajaxLoad(url('admin', 'verify_users_reject'), 'verifyr', 'id:' . $list->id) . '">' . Lang::translate('VERIFY_USERS_REJECT') . '</a>';
echo ')</span>';
echo ' / Steam ';
if ($list->steamid) {
echo '<span class="c_green">✔</span>';
} else {
echo '<span class="c_red">✖</span>';
}
echo '</div>';
}
示例15: select
/**
* selects only specified items from the Collection
*
* This provides a simple form of filtering on Collections. For each item
* in the collection, it calls the callback function, passing it the item.
* If the callback returns `TRUE`, then the item is retained; if it returns
* `FALSE`, then the item is deleted from the collection.
*
* Note that this should not supersede server-side filtering; the
* `Collection::Select()` method requires that *all* of the data for the
* Collection be retrieved from the server before the filtering is
* performed; this can be very inefficient, especially for large data
* sets. This method is mostly useful on smaller-sized sets.
*
* Example:
* <code>
* $services = $connection->ServiceList();
* $services->Select(function($item){ return $item->region=='ORD';});
* // now the $services Collection only has items from the ORD region
* </code>
*
* `Select()` is *destructive*; that is, it actually removes entries from
* the collection. For example, if you use `Select()` to find items with
* the ID > 10, then use it again to find items that are <= 10, it will
* return an empty list.
*
* @api
* @param callable $testfunc a callback function that is passed each item
* in turn. Note that `Select()` performs an explicit test for
* `FALSE`, so functions like `strpos()` need to be cast into a
* boolean value (and not just return the integer).
* @returns void
* @throws DomainError if callback doesn't return a boolean value
*/
public function select($testfunc)
{
foreach ($this->getItemList() as $index => $item) {
$test = call_user_func($testfunc, $item);
if (!is_bool($test)) {
throw new Exceptions\DomainError(Lang::translate('Callback function for Collection::Select() did not return boolean'));
}
if ($test === false) {
unset($this->itemList[$index]);
}
}
}