本文整理汇总了PHP中CacheEngine::CacheLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheEngine::CacheLanguage方法的具体用法?PHP CacheEngine::CacheLanguage怎么用?PHP CacheEngine::CacheLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheEngine
的用法示例。
在下文中一共展示了CacheEngine::CacheLanguage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: intval
<?php
//insert the language keys
$page = intval($_GET['language_insert']);
if (file_exists(FORUM_ROOT . '/app_config/cache/install/language/' . $page . '.php')) {
include FORUM_ROOT . '/app_config/cache/install/language/' . $page . '.php';
redirect('install.php?language_insert=' . ($page + 1));
} else {
$base_config = array('baseurl' => get_cookie_data('baseurl'));
CacheEngine::CacheLanguage();
?>
<form action="install.php" method="post" enctype="multipart/form-data">
<p><?php
echo translate('continuetocompleteinstall');
?>
</p>
<p><input type="submit" name="language_done" value="<?php
echo translate('continue');
?>
" /></p>
</form>
<?php
}
示例2: translate
function translate()
{
global $futurebb_user, $base_config;
static $lang;
if (!isset($lang)) {
//is there a cache file present? if not, we need to make one
if (!file_exists(FORUM_ROOT . '/app_config/cache/language/' . basename($futurebb_user['language']) . '/main.php')) {
CacheEngine::CacheLanguage();
}
//is there still not a cache file present? then we don't have a valid language
if (!file_exists(FORUM_ROOT . '/app_config/cache/language/' . basename($futurebb_user['language']) . '/main.php')) {
error('Invalid language file specified');
}
include FORUM_ROOT . '/app_config/cache/language/' . basename($futurebb_user['language']) . '/main.php';
}
if (func_num_args() == 0) {
trigger_error('A text string was not provided to the translate function', E_USER_ERROR);
}
$args = func_get_args();
if ($args[0] == '<addfile>') {
include FORUM_ROOT . '/app_config/cache/language/' . basename($futurebb_user['language']) . '/' . $args[1] . '.php';
$lang = array_merge($lang, $lang_addl);
}
if (!isset($lang[$args[0]])) {
return 'Translator error: ' . $args[0] . ' is not a valid language key';
}
$returnstr = $lang[$args[0]];
if (func_num_args() > 1) {
unset($args[0]);
foreach ($args as $key => $arg) {
//before doing basic replacement, do "smart" replacement
$returnstr = preg_replace_callback('%\\<SWITCH \\$' . $key . '>\\((.*?)\\)%', function ($matches) use($arg) {
$options = explode(',', $matches[1]);
return $options[intval($arg) - 1];
}, $returnstr);
$returnstr = preg_replace_callback('%\\<PLURAL \\$' . $key . '>\\((.*?),(.*?)\\)%', function ($matches) use($arg) {
if ($arg == 1) {
return $matches[1];
} else {
return $matches[2];
}
}, $returnstr);
$returnstr = preg_replace('%\\$' . $key . '([^0-9]|$)%', $arg . '$1', $returnstr);
}
}
return $returnstr;
}