我正在尝试本地化我的插件,通过一个名为CodeStyleing本地化的插件,我成功地创建了一个。采购订单文件。然而,我的插件中使用的单词仍然是英语,尽管默认语言设置为日语,如wp configdefine(“WPLANG”,“ja”)中所定义;
其他本地化插件已正确翻译,包括另一个相关POST插件和WP多字节补丁。
这是我为测试插件本地化而编写的一个示例插件。我尽量保持简单。
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 "やあ!"
这两个文件都保存为UTF-8,没有BOM表。我做错了什么?
*已更新代码,但问题仍然存在。