<?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 }
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; }