本文整理汇总了PHP中Parser::getFunctionLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::getFunctionLang方法的具体用法?PHP Parser::getFunctionLang怎么用?PHP Parser::getFunctionLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser::getFunctionLang方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatDate
/**
* @param Parser $parser
* @param string $date
* @param string $defaultPref
*
* @return string
*/
static function formatDate($parser, $date, $defaultPref = null)
{
$lang = $parser->getFunctionLang();
$df = DateFormatter::getInstance($lang);
$date = trim($date);
$pref = $parser->getOptions()->getDateFormat();
// Specify a different default date format other than the the normal default
// if the user has 'default' for their setting
if ($pref == 'default' && $defaultPref) {
$pref = $defaultPref;
}
$date = $df->reformat($pref, $date, array('match-whole'));
return $date;
}
示例2: bidi
/**
* @param Parser $parser
* @param string $text
* @return string
*/
public static function bidi($parser, $text = '')
{
return $parser->getFunctionLang()->embedBidi($text);
}
示例3: pagesize
/**
* Return the size of the given page, or 0 if it's nonexistent. This is an
* expensive parser function and can't be called too many times per page.
*
* @param Parser $parser
* @param string $page Name of page to check (Default: empty string)
* @param string $raw Should number be human readable with commas or just number
* @return string
*/
public static function pagesize($parser, $page = '', $raw = null)
{
$title = Title::newFromText($page);
if (!is_object($title)) {
return self::formatRaw(0, $raw, $parser->getFunctionLang());
}
// fetch revision from cache/database and return the value
$rev = self::getCachedRevisionObject($parser, $title);
$length = $rev ? $rev->getSize() : 0;
if ($length === null) {
// We've had bugs where rev_len was not being recorded for empty pages, see T135414
$length = 0;
}
return self::formatRaw($length, $raw, $parser->getFunctionLang());
}
示例4: plural
/**
* @param Parser $parser
* @param string $text
* @return string
*/
public static function plural($parser, $text = '')
{
$forms = array_slice(func_get_args(), 2);
$text = $parser->getFunctionLang()->parseFormattedNumber($text);
settype($text, ctype_digit($text) ? 'int' : 'float');
return $parser->getFunctionLang()->convertPlural($text, $forms);
}