當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utilities::SetLanguage方法代碼示例

本文整理匯總了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");
?>
&mdash;<?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 
開發者ID:eavesmonkey,項目名稱:respond,代碼行數:31,代碼來源:account.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");
?>
&mdash;<?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';
?>
開發者ID:eavesmonkey,項目名稱:respond,代碼行數:31,代碼來源:undefined.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) {
//.........這裏部分代碼省略.........
開發者ID:eavesmonkey,項目名稱:respond,代碼行數:101,代碼來源:Utilities.php

示例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);
     }
 }
開發者ID:eavesmonkey,項目名稱:respond,代碼行數:53,代碼來源:page.php

示例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');
開發者ID:eavesmonkey,項目名稱:respond,代碼行數:29,代碼來源:site.php


注:本文中的Utilities::SetLanguage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。