I'm trying to localize my plugin and with a plugin called CodeStyling Localization, I succeeded to create a .po file. However, the words used in my plugin remain in English although the default language is set to Japanese as defined in wp-configdefine('WPLANG', 'ja');
Other localized plugins are properly translated including, Yet Another Related Posts Plugin and WP Multibyte Patch.
This is a sample plugin I wrote to test plugin localization. I kept it as simple as possible.
wp-content\plugins\localizationsample\localizationsample.php
<?php
/*
Plugin Name: Localization Sample Plugin
Version: 1.1
Author: Teno
*/
// Localization
add_action('init', 'localizationsample_init');
function localizationsample_init() {
$loaded = load_plugin_textdomain('localizationsample', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/');
}
// Add Admin Menu
add_action('admin_menu','localizationsample_menu');
function localizationsample_menu() {
add_options_page(
'Localization Sample Plugin',
'Localization Sample Plugin',
'manage_options',
__FILE__,
'localizationsample_adminpanel'
);
}
function localizationsample_adminpanel() {
echo '<div class="wrap"><div id="icon-themes" class="icon32"></div>';
echo '<h2>' . __('hi!', 'localizationsample') . '</h2>'; // "hi!" should be translated.
echo '</div></div>';
}
?>
wp-content\plugins\localizationsample\lang\LSample-ja_JP.po
msgid ""
msgstr ""
"Project-Id-Version: Localization Sample Plugin v1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-08-17 20:23+0900\n"
"PO-Revision-Date: 2012-08-17 11:27:39+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Poedit-Language: \n"
"X-Poedit-Country: \n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-Bookmarks: \n"
"X-Poedit-SearchPath-0: Z:/xampp/htdocs/wptest/wp-content/plugins/localizationsample\n"
"X-Textdomain-Support: yes"
#: localizationsample.php:28
#@ LSample
msgid "hi!"
msgstr "やあ!"
Both files are saved as UTF-8 without BOM. What am I doing wrong?
*updated the code but the issue still persists.