Esempio n. 1
0
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>";
    }
}
Esempio n. 2
0
        $sql = "SELECT * FROM form_fields WHERE `field_type`='RADIO' or `field_type`='CHECK' or `field_type`='MSELECT' or `field_type`='SELECT'  ";
        $result = JB_mysql_query($sql) or die(mysql_error() . $sql);
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            JB_format_codes_translation_table($row['field_id']);
        }
        // update forms
        // (copy English to new lang)
        JB_format_field_translation_table(1);
        JB_format_field_translation_table(2);
        JB_format_field_translation_table(3);
        JB_format_field_translation_table(4);
        JB_format_field_translation_table(5);
        // update email templates
        JB_format_email_translation_table();
        preg_match('#([a-z0-9_\\-]+)#i', stripslashes($_REQUEST['jb_theme']), $m);
        $lang_file = JB_get_theme_dir() . $m[1] . "/lang/english_default.php";
        if (file_exists($lang_file)) {
            JB_merge_language_files(true);
            echo '<br><br>';
        }
        @touch("../config.php");
        // update config.php timestamp.
        $JBMarkup->ok_msg('Language Updated.');
        $_REQUEST['action'] = '';
    }
}
?>

<table border="0" cellSpacing="1" cellPadding="3" bgColor="#d9d9d9" >
			<tr bgColor="#eaeaea">
				<td><b><font size="2">Language</b></font></td>
Esempio n. 3
0
function JB_theme_append_english_default_labels()
{
    global $label;
    // include label form current theme
    global $JB_LANG_THEMES;
    $themes = array_unique($JB_LANG_THEMES);
    if (!in_array(JB_THEME, $themes)) {
        $themes['EN'] = JB_THEME;
    }
    foreach ($themes as $key => $theme) {
        $theme_path = JB_get_theme_dir() . $theme . '/';
        //echo $theme_path.'lang/english_default.php <br>';
        if (file_exists($theme_path . 'lang/english_default.php')) {
            require $theme_path . 'lang/english_default.php';
        }
    }
    return;
    /*
    $theme_lang = JB_THEME_PATH."lang/english_default.php";
    if (file_exists($theme_lang)) {
    		require ($theme_lang);
    	}
    */
}