本文整理汇总了PHP中Translation::Language方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::Language方法的具体用法?PHP Translation::Language怎么用?PHP Translation::Language使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::Language方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: t
/**
* Short function to get translation
*
* Acts as a _() alternative. Will also log missing translations.
*
* @param string $key The key to translate (example: HELLO_WORLD)
*
* @return string Will return proper translation, hard-coded value or given key.
*/
function t($key)
{
if (!empty($key)) {
$translation = Translation::Get($key);
if (!is_null($translation)) {
return $translation;
} else {
if ($key == 'PAGE_TITLE') {
return PAGE_TITLE;
} else {
if ($key == 'YEAR') {
return date('Y');
} else {
if ($key == 'USERNAME' && LOGGEDIN) {
return session('username');
} else {
Lightwork::Log(sprintf('Missing translation key: %s (%s)', $key, Translation::Language()), Lightwork::LOG_DEBUG);
}
}
}
}
}
return $key;
}
示例2: dirname
/**
* File used for general HTML 5 templating
*
* This file contains the basic templating needed for a properly valid HTML 5 page (doctype, head, body, ...)
*
* @author Perfler Dominik <domi@secnd.me>
* @copyright 2014-2015 Perfler Dominik
* @license MIT
*/
require_once dirname(__FILE__) . '/bootstrap.php';
// Bootstrap this request
?>
<!DOCTYPE html>
<html lang="<?php
echo Translation::Language();
?>
">
<head>
<?php
Template::Load('page/head');
?>
</head>
<?php
flush();
?>
<body>
<?php
Template::Load('page/jsvars');
Template::Load('page/loader');
Menu::Draw('navigation');
示例3: Initialize
/**
* Function to get the "heart" beating
*
* After all the nasty PHP stuff is done (sessions, database, error handling, configuration, ...) we can finally get started with Lightwork...
*
* @param mixed $status If set together with $message an error page will be forced to display.
* @param string $message If set together with $status an error page will be forced to display.
*/
static function Initialize($status = null, $message = null)
{
if (isset($_GET['page']) || $status != null) {
header('Content-Type: text/html; charset=utf-8');
// Twice is better than once - set the charset and content-type
header('Content-Language: ' . Translation::Language());
// Set the content-language to the current translation language
self::$pages = Cache::Read('pages');
// Try to read all pages from cache
if (!self::$pages) {
if (Database::Fetch(LWC::QUERY_PAGES)) {
self::$pages = Database::Data();
// We got the pages, saving them...
Cache::Write('pages', self::$pages);
// ...and caching them.
}
}
ResourceHandler::Initialize();
// Initialize the resource handler - essentially it loads all stylesheets and javascripts
if (DEBUG_MAKEALL) {
ResourceHandler::MakeAll(STYLES);
}
// Incase it is required we will compile & minify all stylesheets and scripts (might make requests slow - debugging only)
if ($status == null) {
if (!empty($_GET['page'])) {
self::HandlePage($_GET['page']);
} else {
self::HandlePage();
}
// Page parameter is empty or not set - page handler will use index by default
unset($_GET['page']);
// Unset the original page parameter from $_GET array...
unset($_REQUEST['page']);
// ...and $_REQUEST array.
} else {
self::SetError($status, $message);
}
// Since we need to force an error we are doing so now.
self::$request = self::REQUEST_PAGE;
// Set the request type
Lightwork::Log(sprintf('This is a page request. (%s)', self::$page['key']), Lightwork::LOG_DEBUG);
// Log this successfully handled request
} else {
if (isset($_GET['script'])) {
self::$scripts = Cache::Read('scripts');
// Attempt to read enabled scripts from cache
if (!self::$scripts) {
if (Database::Fetch(LWC::QUERY_SCRIPTS)) {
self::$scripts = Database::Data();
// We got the scripts, lets save them...
Cache::Write('scripts', self::$scripts);
// ...and cache them.
}
}
if (!empty($_GET['script'])) {
self::HandleScript($_GET['script']);
} else {
self::SetError('error', 'ERROR_BAD_REQUEST');
}
//There is no default so we fail...
unset($_GET['script']);
// Unset the original script from $_GET...
unset($_REQUEST['script']);
// ...and $_REQUEST.
self::$request = self::REQUEST_SCRIPT;
// Set this request as a script request
Lightwork::Log(sprintf('This is a script request. (%s)', self::$script['key']), Lightwork::LOG_DEBUG);
// Log this successful script handling
} else {
if (isset($_GET['file'])) {
self::$files = Cache::Read('files');
// Attempt to read available files from cache
if (!self::$files) {
if (Database::Fetch(LWC::QUERY_FILES)) {
self::$files = Database::Data();
// We got the files, saving them for now...
Cache::Write('files', self::$files);
// ...and caching them for later.
}
}
// Grab file from parameters, no default
if (!empty($_GET['file'])) {
self::HandleFile($_GET['file']);
}
unset($_GET['file']);
// Unset the original file from $_GET...
unset($_REQUEST['file']);
// ...and $_REQUEST.
self::$request = self::REQUEST_FILE;
// Mark this request as a file request
Lightwork::Log(sprintf('This is a file request. (%s)', self::$file['path']), Lightwork::LOG_DEBUG);
// Log this successful file handling
//.........这里部分代码省略.........
示例4: embed
} else {
Lightwork::Log('Requested script ' . $page['customscript'] . ' could not be found.', Lightwork::LOG_WARN);
}
// The defined script could not be found, log this event
}
$success = embed($page);
// Try to embed this page
if (!$page['partial']) {
echo '</div>';
}
// Close the open container div (if this is no partial site)
if ($success) {
if ($page['cache']) {
$content = ob_get_flush();
// The page was created successfully and we can flush it
Cache::Write('pages/' . Translation::Language() . '/' . $page['id'], $content, $page['cacheduration'], true);
// Write the successfully embeded page to cache
}
} else {
ob_end_clean();
Lightwork::Log('Page is missing: ' . $page['path'] . '.', Lightwork::LOG_WARN);
// Page is missing, log this
Lightwork::Done(404, 'ERROR_PAGE_VANISHED');
// Page did not embed successfully - it is supposed to be there but isn't
}
}
}
}
}
function embed($page)
{