本文整理汇总了PHP中h2o::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP h2o::getOptions方法的具体用法?PHP h2o::getOptions怎么用?PHP h2o::getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类h2o
的用法示例。
在下文中一共展示了h2o::getOptions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: templize
function templize($source)
{
$output = array();
$inline_re = '/^\\s*trans\\s+("(?:[^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'(?:[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')\\s*/';
$block_re = "/^\\s*blocktrans(?:\\s+|\$)/";
$endblock_re = "/^\\s*endblocktrans\$/";
$plural_re = "/^\\s*plural\$/";
$var_re = '{
_\\(
(
"[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | # Double Quote string
\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' # Single Quote String
)
\\)
}x';
$lexer = new H2o_Lexer(h2o::getOptions());
$tokenstream = $lexer->tokenize($source);
$in_block = false;
$is_plural = false;
$singulars = array();
$plurals = array();
while ($t = $tokenstream->next()) {
if ($in_block) {
if ($t->type == 'block' && $t->content == 'endblocktrans') {
if ($is_plural) {
$output[] = sprintf(" ngettext('%s', '%s', \$count)", join('', $singulars), join('', $plurals));
} else {
$output[] = sprintf(" gettext('%s')", join('', $singulars));
}
$singulars = $plurals = array();
$in_block = $is_plural = false;
} elseif ($t->type == 'block' && $t->content == 'plural') {
$is_plural = true;
} elseif ($t->type == 'text') {
if ($is_plural) {
$plurals[] = addslashes($t->content);
} else {
$singulars[] = addslashes($t->content);
}
} elseif ($t->type == 'variable') {
@(list($var, $filters) = explode('|', $t->content));
if ($is_plural) {
$plurals[] = sprintf("%%(%s)", $var);
} else {
$singulars[] = sprintf("%%(%s)", $var);
}
} elseif ($t->type == 'block') {
throw new Exception('No block tag is allowed in translation block');
}
} else {
if ($t->type == 'block') {
if (preg_match($inline_re, $t->content, $matches)) {
$output[] = sprintf(" gettext(%s)", $matches[1]);
} elseif (preg_match($block_re, $t->content, $matches)) {
$in_block = true;
}
} elseif ($t->type == 'variable') {
if (preg_match($var_re, $t->content, $matches)) {
$output[] = sprintf(" gettext(%s)", $matches[1]);
}
}
}
}
$result = str_replace("\r", '', implode(";\n", $output));
if ($result) {
return "\n" . $result . ";\n";
}
}