<?PHP
function lang($field, $translatetolng, $prefix, $gtapi, $text) {
        $table = "$prefix" . "LANG";
        mysql_query ("ALTER TABLE `$table` ADD `$field` TEXT NOT NULL");

        if (empty($translatetolng) || $translatetolng == en) {
                echo $text;
        } else {
        $SQL = "SELECT * from $table WHERE CODE = '$translatetolng'"; $result = @mySQL_query( $SQL ); $row = @mySQL_fetch_array( $result );
        echo $row[$field];
                if (empty($row[$field])) {

                        if (!empty($gtapi)) {
                                $text = str_replace(" ", "+", $text);
                                $return = google_translate("$gtapi", "$text", "En", "$translatetolng");
                                echo $return;
                                $sql = "UPDATE $table SET $field = '$return' WHERE CODE = '$translatetolng'";
                                $query = mysql_query($sql);

                        }
                        else
                                echo "";
                }
        }
}

function langcontent($field, $translatetolng, $prefix, $gtapi, $defaultlang, $id, $langtable, $text) {
        $table = $langtable;
        mysql_query ("ALTER TABLE `$table` ADD `$field` TEXT NOT NULL");

        $SQL = "SELECT * from $table WHERE ID = '$id'"; $result = mySQL_query( $SQL ); $row = mySQL_fetch_array( $result );
        echo $row[$field];
                if (empty($row[$field])) {

                        if (!empty($gtapi)) {
                                $text = str_replace(" ", "+", $text);
                                $return = google_translate("$gtapi", "$text", "$defaultlang", "$translatetolng");
                                echo $return;
                                $sql = "UPDATE $table SET $field = '$return' WHERE ID = '$id'";
                                $query = mysql_query($sql);
                        }
                        else
                                echo "";
                }
}
?>
