Categories
Announcement

Nippon 1.1.2 リリース

Nippon プラグインのバージョン 1.1.2 をリリースしました。主な変更点は、

  • From: ヘッダへの Base64 エンコードの適用範囲を必要最小限に限定

    Gmail でも適切に処理できるようになりました。

  • EUC-JP / Shift_JIS / ISO-2022-JP 対応の改良
    • Content-Type: ヘッダが重複して文字化け原因となるケースがあった点を修正
    • From: ヘッダへの Base64 エンコード処理を追加

こちらからダウンロードできます。

もし不具合など見つけられましたらコメントでお知らせ下さい。

Categories
WordPress Tips

poEdit で翻訳ファイルを作る

翻訳ファイル作成の 3 ステップ

先日、プラグインとテーマのローカライズについて主にプラグインやテーマの開発者の視点に立って書きましたが、今度は翻訳をする人の立場で見てみたいと思います。

gettext の翻訳ファイル作成をサポートするツールはいくつかあるようですが、Windows では poEdit が使えます。poEdit の現時点での最新バージョンは 1.3.4 です。

poEdit を使った翻訳ファイル作成作業の流れは次の各段階に分かれます。

  1. ソースコードから翻訳対象のテキストを自動抜粋、.po ファイルを生成する。

    翻訳対象となるテキストは __()_e() のところなので、poEdit はソースファイルをサーチして自動で収集してくれます。生成される .po ファイルはテキストフォーマットのファイルで、次の翻訳作業で編集に使われます。

  2. .po ファイルを編集、翻訳作業を行なう。

    この段階が実際の翻訳作業です。作業は poEdit のインタフェイスから行ないますが、.po ファイルは普通のテキストファイルなので他のエディタで編集することも可能です。

  3. .po ファイルを保存、同時に .mo ファイルが生成される。

    編集した .po ファイルを保存すると同時に .mo ファイルが自動生成されます。.po は人間が読み書きするのに適したテキストファイルであるのに対して、.mo はマシンが高速に読み込むことに適したバイナリファイルです。

既に誰かが .po ファイルを公開していてそれを一部手直しして使いたいだけなら、1 を飛ばして 2 の手順から始めることになります。1 は少々ややこしいので先に 2 の説明から始めます。

Categories
WordPress Plugins

Tam-attachment

I’m busy now. Current version of tam-attachment does not work on WordPress 2.1, but I don’t have time to fix it until March. We’re sorry for the inconvenience.

現行バージョンの tam-attachment は WordPress 2.1 上で機能しません。すぐに直したいのですがしばらく多忙のため3月以降になるまで対応できません。不都合をおわびします。

» 日本語

Summary

Tam-attachment is a WordPress plugin which adds some powerful functionality to native file attachments mechanism. This plugin allows you to edit file title and description at any time, not only at file uploading time. And also it offers a couple of useful features like …

  • Original thumbnail
    You know WordPress takes care of making thumbnail image by scaling original one down automatically. But when the file isn’t an image, WP can’t do that. Tam-attachment’s original thumbnail feature allows you to upload your favorite image as extra thumbnail.
  • After attachment
    When you want to upload big size file like movies, it may over PHP’s limit of upload file size. Then you resignedly upload it via FTP, but FTP uploading can’t make attachment entry on WordPress DB, so the file gets orphaned. Tam-attachment’s after attachment feature help you dig the orphan files up and create attachment entry for them.
  • Tagging
    You can tag the attachments by words. You can also pick up all attachments with specific tag, so it’s useful for grouping attachments.

The plugin has own good-looking edit panels similar to the familiar Post and Page edit panels. You can edit slags, order, discussion settings, password, parent post and custom fields on it.

Tam-attachment screenshot

Categories
WordPress Tips

プラグインとテーマをローカライズする

WordPress のローカライズの基本

WordPress には gettext を利用したローカライゼーション(多言語化、現地語化)の仕組みが組み込まれているので、必要な翻訳ファイルさえ手に入ればわずかな設定で日本語化することが可能です。

簡単に手順をまとめると、

  1. 翻訳ファイル(.mo) を入手する。日本語リソースの情報がこちらにまとめられています
  2. 翻訳ファイルを <WP_INSTALL>/wp-includes/languages/ 以下に配置する。languages というディレクトリは最初はないので自分で作る必要があります。
  3. <WP_INSTALL>/wp-config.php の
    define ('WPLANG', '');
    の行を翻訳ファイルの名前に合わせて書き換える。日本語なら翻訳ファイルが ja.mo なので
    define ('WPLANG', 'ja');
    とします。WPLANG を変更できない場合はファイル名の方を WPLANG に合わせて変更しても問題ないはずです(ja.mo ⇒ ja_UTF.mo とか)。

ところがこの手順で日本語化できるのは基本的には管理パネルの内容だけで、一般の読者が目にするオモテの部分は対象になりません。なぜかというとオモテの部分はテーマでコントロールされているので、テーマのテンプレートに含まれるテキストの日本語化がされない限りオモテは変わらないのです。プラグインについても同様で、プラグインで制御されるテキストのローカライズは個々のプラグインごとに考慮される必要があります。

それではテーマやプラグインの作者がローカライズのために考慮すべきポイントとは何でしょうか。テーマやプラグインにおいても gettext を使用してローカライズすることには変わりありません。テーマやプラグインではその内部で明示的に翻訳ファイル(.mo) をロードする必要があるわけですが、プラグインが翻訳ファイルをロードするために使うのが load_plugin_textdomain() という関数です。

Categories
WordPress Tips

テーマの中にプラグインを

テーマのディレクトリ(<WP_INSTALL>/wp-content/themes/theme-name/)に置くことができるのはビジュアル・テンプレートだけではありません。ディレクトリ内に functions.php という名前のファイルを作っておくと、それが自動的にインクルードされて実行されます。

functions.php はそれを含むテーマが有効化されている場合に限定してインクルードされます。プラグインで実装されるような機能が functions.php で実現されることも良くあります。

実際の使用例を挙げると、Default テーマ (Kubrick) ではヘッダイメージの色を変更できる追加のサブメニューを導入していますが、このメニューの追加などの処理は functions.php の中で書かれています。このようにテーマ固有の機能性を盛り込むことができます。

kubrick-additional-panel.png

これほど大掛かりでなくてもテンプレート内部で複雑なロジックを記述する必要があるような場合は、それらのロジックを functions.php に移動させてテンプレートから関数として呼び出ししたほうが、テンプレートの構造がシンプルでわかりやすくなるでしょう。

Categories
WordPress Plugins

Nippon plugin

注意: このプラグインと tenpura さんによる WP Multibyte Patch を同時に有効にしているとコンフリクトを起こすことが確認されています。WP Multibyte Patch はメールの文字化け回避のほか、WordPress で日本語を正しく処理するために必要となる修正を網羅しているので、WP Multibyte Patch の使用をおすすめします。(2007/11/21 追加)

» 日本語

Summary

This is a plugin for Japanese WordPress users.

This plugin fixes some trouble which users in Japanese environment often face with pure WordPress, like garbles of non-ASCII characters. For now, its ability is just to fix mail garble though, another function will be added when needed.

When you have non-ASCII characters in mail header like Subject: or From:, you must encode them Base64 before you send, but in default WordPress installation wp_mail() does not encode them. It seems that this causes the Japanese character garble problem. Nippon plugin redefines wp_mail() as able to handle encoding process.

This plugin uses mbstring functions inside, so unless your PHP setting activates mbstring module, it’s no use.

Update: Notice: Please do not use this plugin with WordPress 2.2 or greater because it bypasses phpMailer. You can use Nippon 2 plugin with the greater versions.