メッセージを英日併記にするプラグインdebugging translationを作成しました。デバッグ用なので、適用時レイアウト崩れ等が起きる可能性があります。
管理画面に設定オプションを追加するには、register_settingとadd_settings_fieldを利用します。詳細はhttp://wpdocs.sourceforge.jp/Settings_APIをごらんください。
add_action('admin_init','debugging_translation_setting_field');
function debugging_translation_setting_field() {
add_settings_field(
'debugging_translation_glotpress',
'Show GlotPress link',
'debugging_translation_checkbox',
'reading',
'default');
register_setting('reading','debugging_translation_glotpress','intval');
}
function debugging_translation_checkbox(){
echo '<input type="checkbox" name="debugging_translation_glotpress" id="debugging_translation_glotpress" value="1" class="code" ' . checked(get_option('debugging_translation_glotpress'),1, false) . '/>';
}
英日併記にする作業は、gettextフィルタを利用します。単に元テキスト+翻訳後のテキストを返すだけです。
add_filter('gettext','debugging_translation',20,3);
add_filter('ngettext','debugging_translation',20,3);
add_filter('gettext_with_context','debugging_translation',20,3);
add_filter('ngettext_with_context','debugging_translation',20,3);
function debugging_translation($translated_text,$text,$domain) {
if (get_option('debugging_translation_glotpress') && WPLANG) {
$link = '<a href="';
$link .= 'http://translate.wordpress.org/projects/wp/dev/' . WPLANG . '/default?filters%5Bterm%5D=' . urlencode($text);
$link .= '" target="_blank">';
$link .= '→ GlotPress';
$link .= '</a>';
}
return $text . $translated_text . $link ;
}
WordPress 日本語版作成チームでのアドバイスを参考に、バージョン2から、glotPressへのリンクを付けました。
[…] メッセージを英日併記にするプラグインdebugging translation の Concrete5 版を作りました。https://github.com/ounziw/Debugging-translation-for-Concrete5 からダウンロードできます。 […]
[…] Japanese description is also available. […]