Last-modified: 2014-02-04 (火) 18:00:27 (3727d)

 WordPressの日本語対応版の配布を行っているサイトがありました。すばらしい。今後お世話になります。(^^) - 2003.12.23


 WordPressとは、PHP、MySQLを利用したblogツールです。表示される文字列の全日本語化は考えていませんが、とりあえず日本語環境で使えるようにすることはできます。

mbstringを有効に

 なので、PHPのバージョンは4.2以降が望ましいですね。

wp-config-extra.phpで$admin_area_charsetを追加

$admin_area_charset="Shift_JIS";

の1行を追加すると、MySQLのDBにShift_JISのままinsertされます。

http-equivの編集

 各*.phpファイルに点在しているmeta http-equivのcharsetを日本語コードにする。私はほとんどを「Shift_JIS」としました。

<meta http-equiv="ContentType" content="text/html; charset=iso-8859_1"


<meta http-equiv="ContentType" content="text/html; charset=Shift_JIS"

に変更。

RDF、RSSファイルのContent-type、encodingの編集・追加

 XMLをHTTP出力する部分が動作しなくなるので、

header('Content-type: text/xml');

<?php echo "<?xml version=\"1.0\"?".">"; ?>


header('Content-type: text/xml; charset=Shift_JIS');

<?php echo "<?xml version=\"1.0\" encoding=\"Shift_JIS\"?".">"; ?>

のように変更します。

メール送信時の文字化け対策

 http://cgi.no-ip.org/wp/index.php?p=8&c=1 にあるように、

  1. php.iniのmbstring.func_overloadの値を変更するか
  2. mail()関数をmb_send_mail()関数に置き換えるか

です。

trackbackの文字化け対策

 http://cgi.no-ip.org/wp/index.php?p=9&c=1 より。

b2trackback.phpで

// trackback is done by a GET

のコメントの後に

$charset=$HTTP_GET_VARS[’charset’];

を追加。

// trackback is done by a POST

のコメントの後に

$charset=$HTTP_POST_VARS[’charset’];

を追加。

$query = “INSERT INTO $tablecomments VALUES (’0′,’$comment_post_ID’,’>$author’,’$email’,’$tb_url’,’$user_ip’,’$now’,’$comment’,’0′)";

$result = $wpdb->query($query);

の前に

if ($charset==""){$charset="auto";}

else {$charset = strtoupper(trim($charset));}

$comment = mb_convert_encoding($comment,"Shift_JIS", $charset);

$author = mb_convert_encoding($author,"Shift_JIS", $charset);

を挿入。

b2functions.phpのtrackback関数について、

$query_string = “title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt&charset=shift_jis“;

と変更。


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS