本文整理汇总了PHP中Utilities::SetLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Utilities::SetLanguage方法的具体用法?PHP Utilities::SetLanguage怎么用?PHP Utilities::SetLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utilities
的用法示例。
在下文中一共展示了Utilities::SetLanguage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AuthUser
<?php
include 'app.php';
// import php files
$authUser = new AuthUser();
// get auth user
$authUser->Authenticate('Admin');
Utilities::SetLanguage($authUser->Language);
// set language
?>
<!DOCTYPE html>
<html lang="<?php
print str_replace('_', '-', $authUser->Language);
?>
">
<head>
<title><?php
print _("Account");
?>
—<?php
print $authUser->SiteName;
?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- include css -->
<?php
示例2: str_replace
<?php
include 'app.php';
// set language to preferred language (HTTP_ACCEPT_LANGUAGE)
$supported = Utilities::GetSupportedLanguages('');
$language = Utilities::GetPreferredLanguage($supported);
Utilities::SetLanguage($language);
?>
<!DOCTYPE html>
<html lang="<?php
print str_replace('_', '-', $language);
?>
">
<head>
<title><?php
print _("Login");
?>
—<?php
print BRAND;
?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<!-- include styles -->
<?php
include 'modules/css.php';
?>
示例3: BuildSearchIndex
public static function BuildSearchIndex($site, $page, $language, $isDefaultLanguage, $content, $root = '../')
{
$html = str_get_html($content, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT);
$url = $page['FriendlyId'];
$isSecure = 0;
$image = $page['Image'];
if ($page['PageTypeId'] != -1) {
$pageType = PageType::GetByPageTypeId($page['PageTypeId']);
$url = $pageType['FriendlyId'] . '/' . $page['FriendlyId'];
if ($pageType['IsSecure'] == 1) {
$isSecure = 1;
}
}
if ($isDefaultLanguage == false) {
// set language to the domain for the site
$domain = $root . 'sites/' . $site['FriendlyId'] . '/locale';
// set the language
Utilities::SetLanguage($language, $domain);
}
$name = $page['Name'];
$text = '';
$h1s = '';
$h2s = '';
$h3s = '';
$description = $page['Description'];
if ($isDefaultLanguage == false) {
$name = _($name);
// get translated version
$description = _($description);
}
if ($html == null) {
return '';
}
// setup gettext blockquote, h1, h2, h3, p, td, th, li, meta tags for multi-lingual support
foreach ($html->find('blockquote') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('h1') as $el) {
if ($isDefaultLanguage == false) {
$h1s .= _($el->innertext) . ' ';
// get translated version
} else {
$h1s .= $el->innertext . ' ';
}
}
foreach ($html->find('h2') as $el) {
if ($isDefaultLanguage == false) {
$h2s .= _($el->innertext) . ' ';
// get translated version
} else {
$h2s .= $el->innertext . ' ';
}
}
foreach ($html->find('h3') as $el) {
if ($isDefaultLanguage == false) {
$h3s .= _($el->innertext) . ' ';
// get translated version
} else {
$h3s .= $el->innertext . ' ';
}
}
foreach ($html->find('p') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('td') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('th') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('li') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('meta[name=description]') as $el) {
if ($isDefaultLanguage == false) {
//.........这里部分代码省略.........
示例4: get
/**
* @method POST
*/
function get()
{
parse_str($this->request->data, $request);
// parse request
$siteUniqId = SITE_UNIQ_ID;
$pageUniqId = $request['pageUniqId'];
$prefix = $request['prefix'];
// handle reverse lookup
if (strpos($pageUniqId, 'lookup:') !== FALSE) {
$url = str_replace('lookup:', '', $pageUniqId);
$page = Page::GetByUrl($url, SITE_ID);
if ($page != NULL) {
$pageUniqId = $page['PageUniqId'];
}
}
// get language
$language = 'en';
if (isset($request['language'])) {
$language = $request['language'];
}
$site = Site::GetBySiteUniqId($siteUniqId);
// get fragment
$fragment = '../fragments/render/' . $pageUniqId . '.php';
if (file_exists($fragment)) {
// set language to the domain for the site
$domain = '../locale';
Utilities::SetLanguage($language, $domain);
ob_start();
// start output buffer
textdomain($domain);
include $fragment;
$content = ob_get_contents();
// get contents of buffer
ob_end_clean();
// fix nested, relative URLs if displayed in the root
if ($prefix == '') {
$content = str_replace('src="../', 'src="', $content);
$content = str_replace('href="../', 'href="', $content);
}
// update images with sites/[name] to a relative URL
$content = str_replace('src="sites/' . $site['FriendlyId'] . '/', 'src="' . $prefix, $content);
// return html response
$response = new Tonic\Response(Tonic\Response::OK);
$response->contentType = 'text/html';
$response->body = $content;
return $response;
} else {
return new Tonic\Response(Tonic\Response::NOTFOUND);
}
}
示例5: define
<?php
// debugging
define('DEBUG', false);
if (DEBUG) {
error_reporting(E_ALL);
ini_set('display_errors', '1');
} else {
error_reporting(E_ERROR | E_PARSE);
}
session_start();
// authenticate secure pages
if ($isSecure == true) {
$siteAuthUser = new SiteAuthUser($siteFriendlyId, $rootPrefix, $pageUrl);
// get auth user
$siteAuthUser->Authenticate($pageTypeUniqId, $rootPrefix, $pageUrl);
}
// get supported language
$supported = Utilities::GetSupportedLanguages($rootPrefix);
// check if multiple languages are supported
if (count($supported) > 1) {
if (isset($_SESSION[$siteFriendlyId . '.Language'])) {
$language = $_SESSION[$siteFriendlyId . '.Language'];
} else {
// set language as the default language
$_SESSION[$siteFriendlyId . '.Language'] = $language;
}
}
Utilities::SetLanguage($language, $rootPrefix . 'locale');