ㄚ琪沒碰webERP好久了,不過最近碰上一位叫凱凱的網友留言詢問我這個軟體的問題,我也是有碰到類似的問題,所以重新測試安裝,然後修改一些檔案,原則跟Windows weberp 3.11 utf-8 安裝,所以我就不會再贅述!
首先碰到的問題就是,安裝的畫面會出現
這個Unwriteable真的很詭異,以前在Windows weberp 3.11時不會這樣,去查一下權限,發現
這個資料夾的唯讀屬性,一直被打上方塊,不死心拼命地改,就是改不掉,Google找了很多方法,原因可能說是中毒之類的,但無論怎樣就是無法改,後來只好接受,這是微軟針對安全性跟檔案的創作所做的更新造成的,好吧,我就勸凱凱先不用管這個問題直接安裝,確實還是可以安裝的!
但是後來還是發現中文化還是有亂碼的情形,嗯!我想凱凱的問題,跟我碰到的有所不同,因為我發現將sql的編碼改成UTF-8好像無法安裝,不知哪裡錯,不過更新後的webERP要更換到106個編碼,也是挺累的,還是來個工具程式好了,這次Fanrien’s blog的Mysql latin1_swedish_ci 轉 UTF-8,可以很快地將你的資料表轉換成UTF-8編碼,不錯用!
貼上程式碼如下:
<?php
define('DB_NAME', 'putyourdbnamehere'); // 数据库名
define('DB_USER', 'usernamehere'); // MySQL用户名
define('DB_PASSWORD', 'yourpasswordhere'); // 密码
define('DB_HOST', 'localhost'); // 很大可能你无需修改此项
function UTF8_DB_Converter_DoIt() {
$tables = array();
$tables_with_fields = array();
// Since we cannot use the WordPress Database Abstraction Class (wp-db.php),
// we have to make an a stand-alone/direct connection to the database.
$link_id = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Error establishing a database connection');
mysql_select_db(DB_NAME, $link_id);
// Gathering information about tables and all the text/string fields that can be affected
// during the conversion to UTF-8.
$resource = mysql_query("SHOW TABLES", $link_id);
while ( $result = mysql_fetch_row($resource) )
$tables[] = $result[0];
if ( !empty($tables) ) {
foreach ( (array) $tables as $table ) {
$resource = mysql_query("EXPLAIN $table", $link_id);
while ( $result = mysql_fetch_assoc($resource) ) {
if ( preg_match('/(char)|(text)|(enum)|(set)/', $result['Type']) )
$tables_with_fields[$table][$result['Field']] = $result['Type'] . " " . ( "YES" == $result['Null'] ? "" : "NOT " ) . "NULL " . ( !is_null($result['Default']) ? "DEFAULT '". $result['Default'] ."'" : "" );
}
}
// Change all text/string fields of the tables to their corresponding binary text/string representations.
foreach ( (array) $tables as $table )
mysql_query("ALTER TABLE $table CONVERT TO CHARACTER SET binary", $link_id);
// Change database and tables to UTF-8 Character set.
mysql_query("ALTER DATABASE " . DB_NAME . " CHARACTER SET utf8", $link_id);
foreach ( (array) $tables as $table )
mysql_query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8", $link_id);
// Return all binary text/string fields previously changed to their original representations.
foreach ( (array) $tables_with_fields as $table => $fields ) {
foreach ( (array) $fields as $field_type => $field_options ) {
mysql_query("ALTER TABLE $table MODIFY $field_type $field_options", $link_id);
}
}
// Optimize tables and finally close the mysql link.
foreach ( (array) $tables as $table )
mysql_query("OPTIMIZE TABLE $table", $link_id);
mysql_close($link_id);
} else {
die('<strong>There are no tables?</strong>');
}
return true;
}
UTF8_DB_Converter_DoIt();
?>
好了,雖然如此,你可以在安裝後用上面那隻程式幫你UTF-8化,但是可能使用上會發現,不能自動轉為UTF-8的中文畫面,我後來再一次追蹤程式,發現webERP真是夠亂的,這一次竟然又發現有
header(‘Content-type: text/html; charset=’ . _(‘iso-8859-1’));
跟
echo ‘<meta http-equiv=”Content-Type” content=”text/html; charset=’ . _(‘ISO-8859-1’) . ‘” />’;
這樣的程式碼,有點火大了,
只好再更新語系檔一次!zh_TW,直接將檔案解壓縮在locale下即可。
好了,如果你嫌登錄的畫面是英文的不高興,也可以改,就將config.php的$DefaultLanguage =’en_GB’;裡的en_GB改成zh_TW即可!
這樣應該就可以有中文化的webERP了!