plugin translation *.mo file not getting loaded for custom post

Question

I have a weird behaviour.

I have a plugin, with its translation files in the plugin folder languages.

In the plugin page of admin, I see the translation.

enter image description here

In the front-end pages, I see the translation.

enter image description here

In the custom post page in the admin not.

enter image description here

If I move the *.mo file in the wp-content/languages/plugin folder, it works fine.

enter image description here

why? is it a normal behaviour? Am I doing something wrong?

Here’s the code:

Pluginname: interzero_team.php

/*
* Text Domain:   interzero_team
* Domain Path:   /languages
*/

/**
 * create custom post type for the staff members
 */
function interzero_team_create_cpost_staff(){
    
    $labels = array(
        'name'               => esc_html__( 'Team members', 'interzero_team' ),
        'singular_name'      => esc_html__( 'Team member', 'interzero_team' ),
        'add_new'            => esc_html__( 'Add a new member', 'interzero_team' ),
        'add_new_item'       => esc_html__( 'Add a new member', 'interzero_team' ),
        'edit_item'          => esc_html__( 'Edit team member', 'interzero_team' ),
        'new_item'           => esc_html__( 'New team member', 'interzero_team' ),
        'all_items'          => esc_html__( 'Show the team', 'interzero_team' ),
        'view_item'          => esc_html__( 'View a member', 'interzero_team' ),
        'search_items'       => esc_html__( 'Search for a member', 'interzero_team' ),
        'not_found'          => esc_html__( 'No member found', 'interzero_team' ),
        'not_found_in_trash' => esc_html__( 'No member found in the Trash', 'interzero_team' ), 
        'parent_item_colon'  => esc_html__( 'Parent', 'interzero_team' ),
        'menu_name'          => esc_html__( 'Team', 'interzero_team' )
    );
    $args = array(
        'labels'                => $labels,
        'description'           => 'Team members',
        'public'                => true,
        'publicly_queryable'    => true,
        'hierarchical'          => false,
        'menu_position'         => 10,
        'menu_icon'             => 'dashicons-groups',
        'show_in_rest'          => false,
        'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'excerpt', 'post-formats' ),
        'has_archive'           => true,
        'rewrite'               => array(
            'with_front' => false,
            'slug'       => 'staff'
        ),
        'query_var'             => true,
        'taxonomies'            => array('department')
    );
    register_post_type( 'team-member', $args );
}
add_action( 'init' , 'interzero_team_create_cpost_staff', 0);

/**
 * localize
 */
function interzero_team_load_plugin_textdomain() {
    load_plugin_textdomain( 'interzero_team', false, basename( __DIR__ ) . '/languages/' );
}
add_action( 'init', 'interzero_team_load_plugin_textdomain' );

thanks, piero

0
piero 4 weeks 2023-02-23T08:36:06-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse