Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

after a few hours serching on the net I decided to ask here my problem. I'm in a multi site environment and I have this custom post type code:

$products_labels = array(
    'name'                => _x( 'Prodotti', 'General post type name', 'textdomain' ),
    'singular_name'       => _x( 'Prodotto', 'General post type name', 'textdomain' ),
    'menu_name'           => _x( 'Prodotti', 'General post type menu label', 'textdomain' ),
    'parent_item_colon'   => __( 'Genitore elemento:', 'textdomain' ),
    'all_items'           => __( 'Tutti gli elementi', 'textdomain' ),
    'view_item'           => __( 'Vedi', 'textdomain' ),
    'add_new_item'        => __( 'Aggiungi nuovo elemento', 'textdomain' ),
    'add_new'             => __( 'Aggiungi nuovo', 'textdomain' ),
    'edit_item'           => __( 'Modifica', 'textdomain' ),
    'update_item'         => __( 'Aggiorna', 'textdomain' ),
    'search_items'        => __( 'Cerca', 'textdomain' ),
    'not_found'           => __( 'Non trovato', 'textdomain' ),
    'not_found_in_trash'  => __( 'Non trovato nel cestino', 'textdomain' ),
);
$products_args = array(
    'label'               => __( 'Prodotti', 'textdomain' ),
    'description'         => __( 'Prodotti', 'textdomain' ),
    'labels'              => $products_labels,
    'supports'            => array( 'title', 'thumbnail', 'editor', 'excerpt', 'revisions', 'page-attributes' ),
    'taxonomies'          => array( 'product_category' ),
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'menu_icon'           => '',
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
);

One of my sites is on german language and the backoffice has been set in german as well. All the strings are correctly translated (the frontend works without problems) and the de_DE.mo file is well loaded but the labels from the admin perspective are not localized and I can't understand why not :(

This is the load text domain

load_theme_textdomain( 'textdomain', THEMEPATH . '/languages' );

pls find the attached image enter image description here

Hope you can help me :(

UPDATE:

I'noticed that all strings written in functions.php file are not translated. The only way to translate them is to insert strings in a new function called on init action.

exemple:

NOT TRANSLATED

$str = __('My string','textdomain');

TRANSLATED:

function my_function_name()
{
    $str = __('My string','textdomain');
    echo $str;
}

add_action('init','my_function_name', 0);

UPDATE 2:

SOLVED. You have to load the load_theme_textdomain not by action but directly written as first line on the file functions.php Now my custom post type labels are finally translated :)

share|improve this question
1  
what action do you call load_theme_textdomain on, and on what action do you set those vars? –  Milo Apr 30 at 16:38
    
Hello, Milo...load_text_domain is loaded by the "after_setup_theme" action and the custom post type is loaded with an "init" action... –  user2660802 May 2 at 6:48
    
You can post your solution as an answer and accept it. –  simonthesorcerer May 3 at 15:27

1 Answer 1

up vote 0 down vote accepted

SOLVED. You have to load the load_theme_textdomain not by action but directly written as first line on the file functions.php Now my custom post type labels are finally translated :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.