doudeng1870 2013-11-16 09:30
浏览 31
已采纳

WordPress本地化不适用于插件

I have a plugin to be translated. I have done following tasks:

Loaded the TextDomain:

$my_td = 'mysignup';
function my_signup_textdomain_init() {
    global $my_td;
    load_plugin_textdomain( $my_td, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action('plugins_loaded', 'my_signup_textdomain_init');

Added language files(po, pot, mo) in wp_plugin_folder\my_signup\languages (for Bengali bn_BD):

  • mysignup.pot
  • mysignup.mo
  • bn_BD.po
  • bn_BD.mo

Changed the language code in wp_config.php file:

define('WPLANG', 'bn_BD');

But problem is nothing is changed. I am not sure what i have done as mistake. I already read lots of articles and answers. Still i need help to know how can i test everything is fine that i have done and how can i solve the issue.

Please help me. Thanks in advance.

  • 写回答

1条回答 默认 最新

  • dpkajqd31574096 2013-11-16 09:48
    关注

    First of all - what is global $nl_td; did you mean global $my_td; ?

    Second - you seem to miss the .po file ( e.g. mysignup.po ) - and you do not need bn_BD.po and bn_BD.mo

    Third - try to load like this ( without the unnecessary variable ) :

    load_plugin_textdomain( 'mysignup', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    

    Fourth - Make sure ALL your strings are like so : __('string','mysignup');

    EDIT I after comment :

    In your comment you wrote :

    __('First Name field is required', $nl_td) and _e('First Name field is required', $nl_td)

    Again - As far as I can tell from your very restricted code - $nl_td is not defined . $my_td is defined .

    Just replace all those variables with a simple string mysignup .

    Your code is probably some kind of cut&paste - but you must understand what those variables mean if you want them to work correctly, or make sure they are consistent all over .

    Edit II( now that you edited comment from $nl_td to $my_td it seems you start to understand - edit also your code .. :-) then it will work as long as it is global. but better just write a string . )

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!