本文整理汇总了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'));
}