📄 acp_language.php
字号:
// Get email templates $email_templates = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'email', 'txt'); $email_templates = $email_templates['email/']; // Get acp files $acp_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'acp', $phpEx); $acp_files = $acp_files['acp/']; // Get mod files $mod_files = filelist($phpbb_root_path . 'language/' . $row['lang_iso'], 'mods', $phpEx); $mod_files = (isset($mod_files['mods/'])) ? $mod_files['mods/'] : array(); // Add main files $this->add_to_archive($compress, $this->main_files, $row['lang_iso']); // Add search files if they exist... if (file_exists($phpbb_root_path . 'language/' . $row['lang_iso'] . '/search_ignore_words.' . $phpEx)) { $this->add_to_archive($compress, array("search_ignore_words.$phpEx"), $row['lang_iso']); } if (file_exists($phpbb_root_path . 'language/' . $row['lang_iso'] . '/search_synonyms.' . $phpEx)) { $this->add_to_archive($compress, array("search_synonyms.$phpEx"), $row['lang_iso']); } // Write files in folders $this->add_to_archive($compress, $email_templates, $row['lang_iso'], 'email'); $this->add_to_archive($compress, $acp_files, $row['lang_iso'], 'acp'); $this->add_to_archive($compress, $mod_files, $row['lang_iso'], 'mods'); // Write ISO File $iso_src = htmlspecialchars_decode($row['lang_english_name']) . "\n"; $iso_src .= htmlspecialchars_decode($row['lang_local_name']) . "\n"; $iso_src .= htmlspecialchars_decode($row['lang_author']); $compress->add_data($iso_src, 'language/' . $row['lang_iso'] . '/iso.txt'); // index.html files $compress->add_data('', 'language/' . $row['lang_iso'] . '/index.html'); $compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.html'); $compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.html'); if (sizeof($mod_files)) { $compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.html'); } $compress->close(); $compress->download('lang_' . $row['lang_iso']); @unlink($phpbb_root_path . 'store/lang_' . $row['lang_iso'] . $use_method); exit; break; } $sql = 'SELECT user_lang, COUNT(user_lang) AS lang_count FROM ' . USERS_TABLE . ' GROUP BY user_lang'; $result = $db->sql_query($sql); $lang_count = array(); while ($row = $db->sql_fetchrow($result)) { $lang_count[$row['user_lang']] = $row['lang_count']; } $db->sql_freeresult($result); $sql = 'SELECT * FROM ' . LANG_TABLE . ' ORDER BY lang_english_name'; $result = $db->sql_query($sql); $installed = array(); while ($row = $db->sql_fetchrow($result)) { $installed[] = $row['lang_iso']; $tagstyle = ($row['lang_iso'] == $config['default_lang']) ? '*' : ''; $template->assign_block_vars('lang', array( 'U_DETAILS' => $this->u_action . "&action=details&id={$row['lang_id']}", 'U_DOWNLOAD' => $this->u_action . "&action=download&id={$row['lang_id']}", 'U_DELETE' => $this->u_action . "&action=delete&id={$row['lang_id']}", 'ENGLISH_NAME' => $row['lang_english_name'], 'TAG' => $tagstyle, 'LOCAL_NAME' => $row['lang_local_name'], 'ISO' => $row['lang_iso'], 'USED_BY' => (isset($lang_count[$row['lang_iso']])) ? $lang_count[$row['lang_iso']] : 0, )); } $db->sql_freeresult($result); $new_ary = $iso = array(); $dp = @opendir("{$phpbb_root_path}language"); if ($dp) { while (($file = readdir($dp)) !== false) { if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt")) { if (!in_array($file, $installed)) { if ($iso = file("{$phpbb_root_path}language/$file/iso.txt")) { if (sizeof($iso) == 3) { $new_ary[$file] = array( 'iso' => $file, 'name' => trim($iso[0]), 'local_name'=> trim($iso[1]), 'author' => trim($iso[2]) ); } } } } } closedir($dp); } unset($installed); if (sizeof($new_ary)) { foreach ($new_ary as $iso => $lang_ary) { $template->assign_block_vars('notinst', array( 'ISO' => htmlspecialchars($lang_ary['iso']), 'LOCAL_NAME' => htmlspecialchars($lang_ary['local_name'], ENT_COMPAT, 'UTF-8'), 'NAME' => htmlspecialchars($lang_ary['name'], ENT_COMPAT, 'UTF-8'), 'U_INSTALL' => $this->u_action . '&action=install&iso=' . urlencode($lang_ary['iso'])) ); } } unset($new_ary); } /** * Set default language variables/header */ function default_variables() { global $phpEx; $this->language_file_header = '<?php/** ** {FILENAME} [{LANG_NAME}]** @package language* @copyright (c) ' . date('Y') . ' phpBB Group * @author {CHANGED} - {AUTHOR}* @license http://opensource.org/licenses/gpl-license.php GNU Public License **//*** DO NOT CHANGE*/if (empty($lang) || !is_array($lang)){ $lang = array();}// DEVELOPERS PLEASE NOTE//// All language files should use UTF-8 as their encoding and the files must not contain a BOM.//// Placeholders can now contain order information, e.g. instead of// \'Page %s of %s\' you can (and should) write \'Page %1$s of %2$s\', this allows// translators to re-order the output of data while ensuring it remains correct//// You do not need this where single placeholders are used, e.g. \'Message %d\' is fine// equally where a string contains only two placeholders which are used to wrap text// in a url you again do not need to specify an order e.g., \'Click %sHERE%s\' is fine'; $this->lang_header = '$lang = array_merge($lang, array('; // Language files in language root directory $this->main_files = array("common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx"); } /** * Get filename/location of language file */ function get_filename($lang_iso, $directory, $filename, $check_store = false, $only_return_filename = false) { global $phpbb_root_path, $safe_mode; $check_filename = "language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename; if ($check_store) { $check_store_filename = ($safe_mode) ? "store/langfile_{$lang_iso}" . (($directory) ? '_' . $directory : '') . "_{$filename}" : "store/language/$lang_iso/" . (($directory) ? $directory . '/' : '') . $filename; if (!$only_return_filename && file_exists($phpbb_root_path . $check_store_filename)) { return $check_store_filename; } else if ($only_return_filename) { return $check_store_filename; } } return $check_filename; } /** * Add files to archive */ function add_to_archive(&$compress, $filelist, $lang_iso, $directory = '') { global $phpbb_root_path; foreach ($filelist as $file) { // Get source filename $source = $this->get_filename($lang_iso, $directory, $file, true); $destination = 'language/' . $lang_iso . '/' . (($directory) ? $directory . '/' : '') . $file; // Add file to archive $compress->add_custom_file($phpbb_root_path . $source, $destination); } } /** * Little helper to add some hardcoded template bits */ function add_input_field() { $keys = func_get_args(); $non_static = array_shift($keys); $value = array_shift($keys); if (!$non_static) { return '<strong>' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '</strong>'; } // If more then 270 characters, then we present a textarea, else an input field $textarea = (utf8_strlen($value) > 270) ? true : false; $tpl = ''; $tpl .= ($textarea) ? '<textarea name="' : '<input type="text" name="'; $tpl .= 'entry[' . implode('][', array_map('utf8_htmlspecialchars', $keys)) . ']"'; $tpl .= ($textarea) ? ' cols="80" rows="5" class="langvalue">' : ' class="langvalue" value="'; $tpl .= htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); $tpl .= ($textarea) ? '</textarea>' : '" />'; return $tpl; } /** * Print language entries */ function print_language_entries(&$lang_ary, $key_prefix = '', $input_field = true) { $tpl = ''; foreach ($lang_ary as $key => $value) { if (is_array($value)) { // Write key $tpl .= ' <tr> <td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</strong></td> </tr>'; foreach ($value as $_key => $_value) { if (is_array($_value)) { // Write key $tpl .= ' <tr> <td class="row3" colspan="2">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . ' <strong>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</strong></td> </tr>'; foreach ($_value as $__key => $__value) { // Write key $tpl .= ' <tr> <td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($__key, ENT_COMPAT, 'UTF-8') . '</strong></td> <td class="row2">'; $tpl .= $this->add_input_field($input_field, $__value, $key, $_key, $__key); $tpl .= '</td> </tr>'; } } else { // Write key $tpl .= ' <tr> <td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($_key, ENT_COMPAT, 'UTF-8') . '</strong></td> <td class="row2">'; $tpl .= $this->add_input_field($input_field, $_value, $key, $_key); $tpl .= '</td> </tr>'; } } $tpl .= ' <tr> <td class="spacer" colspan="2"> </td> </tr>'; } else { // Write key $tpl .= ' <tr> <td class="row1" style="white-space: nowrap;">' . htmlspecialchars($key_prefix, ENT_COMPAT, 'UTF-8') . '<strong>' . htmlspecialchars($key, ENT_COMPAT, 'UTF-8') . '</strong></td> <td class="row2">'; $tpl .= $this->add_input_field($input_field, $value, $key); $tpl .= '</td> </tr>'; } } return $tpl; } /** * Compare two language files */ function compare_language_files($source_lang, $dest_lang, $directory, $file) { global $phpbb_root_path, $phpEx; $return_ary = array(); $lang = array(); include("{$phpbb_root_path}language/{$source_lang}/" . (($directory) ? $directory . '/' : '') . $file); $lang_entry_src = $lang; $lang = array(); if (!file_exists($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true))) { return array(); } include($phpbb_root_path . $this->get_filename($dest_lang, $directory, $file, true)); $lang_entry_dst = $lang; unset($lang); $diff_array_keys = array_diff(array_keys($lang_entry_src), array_keys($lang_entry_dst)); unset($lang_entry_dst); foreach ($diff_array_keys as $key) { $return_ary[$key] = $lang_entry_src[$key]; } unset($lang_entry_src); return $return_ary; } /** * Return language string value for storage */ function prepare_lang_entry($text, $store = true) { $text = (STRIP) ? stripslashes($text) : $text; // Adjust for storage... if ($store) { $text = str_replace("'", "\\'", str_replace('\\', '\\\\', $text)); } return $text; } /** * Format language array for storage */ function format_lang_array($key, $value, $tabs = "\t") { $entry = ''; if (!is_array($value)) { $entry .= "{$tabs}'{$key}'\t=> '" . $this->prepare_lang_entry($value) . "',\n"; } else { $_tabs = $tabs . "\t"; $entry .= "\n{$tabs}'{$key}'\t=> array(\n"; foreach ($value as $_key => $_value) { $entry .= $this->format_lang_array($_key, $_value, $_tabs); } $entry .= "{$tabs}),\n\n"; } return $entry; }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -