Support » Developing with WordPress » My plugins languages not wording?

  • Resolved bearshang


    this is enter file:
    // Load Plugins Languages
    load_plugin_textdomain( ‘trueniu-init’, false, dirname( plugin_basename( __FILE__ ) ) . ‘/languages/’ );

    // Load Init
    new \Trueniu\Core\Init();

    // Load Custom Function
    require TNABSPATH . ‘/trueniu-functions.php’;

    but when i use __(‘Add New’, ‘trueniu-init’),it no change,translate fail.

    this is my .po
    #: Trueniu\Abstracts\AbstractPost:90
    #, php-format
    msgid “Add New”
    msgstr “新增”

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz


    Hi bear,

    Please review the Localization page in the Plugin Handbook. You need to compile a .mo file using msgfmt with your .po file as input. The .mo file must be correctly named and located in the proper location within the WP directory structure. All plugin .mo files are stored in the same place. The .pot and .po files are only a means to an end. WP does not directly use these, only the .mo file is used.

    I’m not sure how important the first part of .po files are, but if you look at the .po files of other repository plugins, you’ll see they all have a number of standard meta data entries following msgid ""{ \n }msgstr "". This data will appear in the final .mo file as well. Even if it’s not required, you should provide the information anyway.

    hello @bcworkz
    thank you very much answer my question,
    I solved it
    I was loading the language file in the plugin before:
    load_plugin_textdomain( 'trueniu-init', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

    just now,And he is working:

    // Load Plugins Languages
    add_action( 'plugins_loaded', 'trueniu_init_load_textdomain' );
    function trueniu_init_load_textdomain()
        load_plugin_textdomain( 'trueniu-init', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘My plugins languages not wording?’ is closed to new replies.