function JB_merge_language_files($force_update = false) { if (JB_DEMO_MODE == 'YES') { return; } global $label; // load in the main english_default labels $source_label = array(); include_once jb_get_english_default_dir() . 'english_default.php'; // the master lang/english_default $source_label = array_merge($source_label, $label); // default english labels unset($label); $label = array(); $last_mtime = filemtime(jb_get_english_default_dir() . 'english_default.php'); // load the english_default.php labels for all themes // global $JB_LANG_THEMES; $themes = $JB_LANG_THEMES; if (isset($_REQUEST['jb_theme'])) { // Admin->Main Config, Admin-> Languagess if (isset($_REQUEST['lang_code'])) { $lang = $_REQUEST['lang_code']; // comes from Admin->Languages } else { $lang = $_SESSION['LANG']; } $themes[$lang] = $_REQUEST['jb_theme']; } $themes = array_unique($themes); // get the english_default.php for each theme foreach ($themes as $key => $theme) { $theme_path = JB_get_theme_dir() . $theme . '/'; if (file_exists($theme_path . 'lang/english_default.php')) { include $theme_path . 'lang/english_default.php'; $source_label = array_merge($source_label, $label); // default english labels unset($label); $label = array(); $m_time = filemtime($theme_path . "lang/english_default.php"); if ($m_time > $last_mtime) { $last_mtime = $m_time; } } } if ($force_update) { $last_mtime = time(); } // Now we should have all the source labels in $source_label and // last modification time in $last_mtime // Grab all the languages installed $sql = "SELECT * FROM lang "; $result = JB_mysql_query($sql) or die(mysql_error()); // Now merge the english_default.php strings with the language files while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // now that we have all the source labels, we can merge them with // the langauge file. Any key that is present in the source, but // not present if (is_writable(jB_get_lang_dir() . $row['lang_filename'])) { if ($last_mtime > filemtime(jB_get_lang_dir() . $row['lang_filename'])) { echo "Merging language strings for " . jb_escape_html($row['lang_filename']) . ".. <br>"; // Now merge the english defaults with the langauge file include jB_get_lang_dir() . $row['lang_filename']; // customized labels $dest_label = array_merge($source_label, $label); $label = null; // write out the new file: $out = "<?php\n"; $out .= "///////////////////////////////////////////////////////////////////////////\n"; $out .= "// IMPORTANT NOTICE\n"; $out .= "///////////////////////////////////////////////////////////////////////////\n"; $out .= "// This file was generated by a script!\n"; $out .= "// (JB_merge_language_files() function)\n"; $out .= "// Please do not edit the language files by hand\n"; $out .= "// - please always use the Language Translation / Editing tool found\n"; $out .= "// in Admin->Languages\n"; $out .= "// To add a new phrase for the \$label, please edit english_default.php, and\n"; $out .= "// then vist Admin->Main Summary where the language files will be\n"; $out .= "// automatically merged with this file.\n"; $out .= "///////////////////////////////////////////////////////////////////////////\n"; foreach ($dest_label as $key => $val) { $val = str_replace("'", "\\'", $val); $out .= "\$label['{$key}']='" . JB_clean_str($val) . "'; \n"; } $out .= "?>\n"; $handler = fopen(jB_get_lang_dir() . $row['lang_filename'], "w"); fputs($handler, $out); fclose($handler); } } else { echo "<font color='red'><b>- " . jB_get_lang_dir() . $row['lang_filename'] . " file is not writable. Give write permissions (" . decoct(JB_NEW_FILE_CHMOD) . ") to " . jB_get_lang_dir() . $row['lang_filename'] . " file and then disable & re-enable this plugin</b></font><br>"; } } if ($out) { echo " Done.<br>"; } }
$handler = fopen(jB_get_lang_dir() . $lang_filename, "w"); fputs($handler, $out); // load the new labels include jB_get_lang_dir() . $lang_filename; $dest_label = $label; // dest labels touch(jb_get_config_dir() . 'config.php'); // update config.php timestamp. } ?> <h3>Jamit Job Board Language Translation tool.</h3> <b>IMPORTANT:</b> Backup your language files before using this tool! This tool will overwrite any code in the target file with machine-generated code. Also, please wait until the page is fully loaded before saving.<br> <?php if (!is_writeable(jB_get_lang_dir() . $lang_filename)) { $JBMarkup->error_msg("<b>Warning:</b></font> The file " . jB_get_lang_dir() . jb_escape_html($lang_filename) . " is not writable. You must give it write permissions for changes to take effect. You may set back to read-only permissions after saving changes."); } ?> <form method="POST" name="form1" action="translation_tool.php"> <div style="background-color: white; border: 2px solid #FF8000; padding:15px; margin:5px;">Caution: HTML tags are allowed in the input, eg. <b>example<b><br> For normal text, please use <b>HTML Entities</b><br> - If you want to use a <B>></B> character, please type in <B>&gt;</B> instead<br> - To use a <B><</B> character, please type in <B>&lt;</B> instead<br> - For an <B>&</B>, please use <B>&amp;</B> instead<br> - For <B>"</B>, please use <B>&quot;</B><br> </div> <input type="hidden" name="target_lang" value="<?php echo jb_escape_html($_REQUEST['target_lang']); ?>
function JBPLUG_merge_english_default_files() { JBPLUG_require_all_plugins(); global $_JB_PLUGINS; $source_label = array(); // load in the main english_default labels include_once jb_get_english_default_dir() . "english_default.php"; // the master lang/english_default $source_label = array_merge($source_label, $label); // default english labels $label = array(); $last_mtime = filemtime(jb_get_english_default_dir() . "english_default.php"); $sql = "SELECT * FROM lang "; $result = JB_mysql_query($sql); // Now merge the english_default.php strings with the language files while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Merging language strings for " . jb_escape_html($row['lang_filename']) . "..<br>"; /// for each of the plugins, load in the plugin's english default foreach ($_JB_PLUGINS as $class => $obj) { $plugin_english_default_path = dirname(__FILE__) . "/plugins/{$class}/lang/english_default.php"; if (!file_exists($plugin_english_default_path)) { continue; // skip } include_once $plugin_english_default_path; // load the labels from the plugins $source_label = array_merge($source_label, $label); $label = array(); $m_time = filemtime($plugin_english_default_path); if ($m_time > $last_mtime) { $last_mtime = $m_time; } } // now that we have all the source labels, we can merge them with // the langauge file. Any key that is present in the source, but // not present in the language file then we merge it. if (is_writable(jB_get_lang_dir() . $row['lang_filename'])) { if ($last_mtime > filemtime(jB_get_lang_dir() . $row['lang_filename'])) { // Now merge the english defaults with the langauge file include jB_get_lang_dir() . $row['lang_filename']; // customized labels $dest_label = array_merge($source_label, $label); $label = array(); // write out the new file: $out = "<?php\n"; $out .= "///////////////////////////////////////////////////////////////////////////\n"; $out .= "// IMPORTANT NOTICE\n"; $out .= "///////////////////////////////////////////////////////////////////////////\n"; $out .= "// This file was generated by a script!\n"; $out .= "// (JBPLUG_merge_english_default_files() function)\n"; $out .= "// Please do not edit the language files by hand\n"; $out .= "// - please always use the Language Translation / Editing tool found\n"; $out .= "// in Admin->Languages\n"; $out .= "// To add a new phrase for the \$label, please edit english_default.php, and\n"; $out .= "// then vist Admin->Main Summary where the language files will be\n"; $out .= "// automatically merged with this file.\n"; $out .= "///////////////////////////////////////////////////////////////////////////\n"; foreach ($dest_label as $key => $val) { $val = str_replace("'", "\\'", $val); $out .= "\$label['{$key}']='" . JB_clean_str($val) . "'; \n"; } $out .= "?>\n"; $handler = fopen(jB_get_lang_dir() . $row['lang_filename'], "w"); fputs($handler, $out); fclose($handler); } } else { echo "<font color='red'><b>- " . jB_get_lang_dir() . $row['lang_filename'] . " file is not writable. Give write permissions (" . decoct(JB_NEW_FILE_CHMOD) . ") to " . jB_get_lang_dir() . $row['lang_filename'] . " file and then disable & re-enable this plugin</b></font><br>"; } echo " Done.<br>"; } }