本文整理匯總了PHP中Translate::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translate::getInstance方法的具體用法?PHP Translate::getInstance怎麽用?PHP Translate::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translate
的用法示例。
在下文中一共展示了Translate::getInstance方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
Registry::set('config', new Config());
// Initializing the language
$translation = Translate::getInstance();
// If requested with ?lang=<lang> we load the language.
$lang = $translation->getLanguageToLoad();
$translation->loadLanguage($lang);
}
示例2: _t
/**
* Get phrase translation
* @param string $phrase to Translate
* @lang string $lang Destination language
*/
function _t($phrase, $lang = null)
{
return Translate::getInstance($lang ? $lang : Config::get("language"))->getPhrase($phrase);
}
示例3: __
function __($message)
{
$message = Translate::getInstance()->get($message);
# if ( !( 'UTF-8' == mb_detect_encoding($message) ) )
# $message = utf8_encode($message);
$params = array_slice(func_get_args(), 1);
foreach ($params as $i => $param) {
if (is_object($param) && method_exists($param, '__toString')) {
$param = $param->__toString();
}
$message = str_replace("\${$i}", $param, $message);
}
return $message;
}
示例4: replace
function replace($link)
{
if (!preg_match('~^http://~', $link[2])) {
$parts = explode('?', $link[2]);
if (empty($parts[1])) {
return $link[0];
}
$lt = Translate::getInstance();
$link[2] = str_replace('&', '&', $link[2]);
$link[2] = $lt->params2cool(Functions::convertQueryStringToArray($parts[1]), $parts[0]);
unset($link[0]);
return implode('', $link);
} else {
return $link[0];
}
}
示例5: preFilterLang
public static function preFilterLang($templateContent)
{
self::$translate = Translate::getInstance(Config::get("language"));
$templateContent = str_replace('|objurl', '|@objurl', $templateContent);
$pattern = '#\\{\'([^\']+)\'\\|lang\\}#';
$templateContent = preg_replace_callback($pattern, array("AppTemplateLiteView", "preFilterLangMatchCallback"), $templateContent);
return $templateContent;
}
示例6: testGetInstance
/**
* @todo Implement testGetInstance().
*/
public function testGetInstance()
{
$instance = Translate::getInstance();
// Check if getInstance() returns correct object.
$this->assertTrue(is_a($instance, 'MongoUI\\Core\\Translate'));
}