1

I am wondering if there is a way to use the "default" text domain ("WordPress" or "default") to translate labels. E.g I have following code:

// Register Custom Taxonomy
function custom_taxonomy() {

$labels = array(
    'name'                       => _x( 'Press category', 'Taxonomy General Name', 'my_text_domain' ),
    'singular_name'              => _x( 'Press category', 'Taxonomy Singular Name', 'my_text_domain' ),
    'menu_name'                  => __( 'Pressekateorien', 'my_text_domain' ),
    'all_items'                  => __( 'All Items' ),
    'parent_item'                => __( 'Parent Item' ),
    'parent_item_colon'          => __( 'Parent Item:' ),
    'new_item_name'              => __( 'New Item Name' ),
    'add_new_item'               => __( 'Add New Item' ),
    'edit_item'                  => __( 'Edit Item' ),
    'update_item'                => __( 'Update Item' ),
    'view_item'                  => __( 'View Item' ),
    'separate_items_with_commas' => __( 'Separate items with commas' ),
    'add_or_remove_items'        => __( 'Add or remove items' ),
    'choose_from_most_used'      => __( 'Choose from the most used' ),
    'popular_items'              => __( 'Popular Items' ),
    'search_items'               => __( 'Search Items' ),
    'not_found'                  => __( 'Not Found' ),
);
$args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => true,
    'show_ui'                    => true,
    'show_admin_column'          => true,
    'show_in_nav_menus'          => true,
    'show_tagcloud'              => false,
);
register_taxonomy( 'category_press', array( 'press' ), $args );

}

// Hook into the 'init' action
add_action( 'init', 'custom_taxonomy', 0 );

As you can see, I am only translating 3 strings ("name", "singular name" and "menu_name" with my_text_domain, the other ones should be translated by the default text domain that WordPress is using in the backend anyway). WPML for example shows me there is a WordPress text domain. I tried to use that as well, but neither default or WordPress works, e.g. I tried:

'all_items'                  => __( 'All Items', 'WordPress' ), // doesn't work
'parent_item'                => __( 'Parent Item', 'default' ), // doesn't work

Any hints?

THANKS!

1 Answer 1

8

If you don't provide any textdomain, WordPress translated strings are used. If you use, for example, __( 'Add New Tag' );, the translation from WordPress core will be used because 'Add New Tag' exists in WordPress.

Your problem is that your are defining labels that don't exist in WordPress core, so they are not included in any WordPress translation files. I mean, strings like 'All Items' or 'Popular Items' don't exist in WordPress and they are not translated anywhere.

I think my explanation is a little tricky, I hope you get what I mean.

1
  • HI cybmeta, oh alright. I see, I actually assumed that "All Items", "Popular Items" etc. are pretty much standard terms since I used the Taxonomy Generator from Generate WP (generatewp.com/taxonomy). I will have to check for the "general" termns in the localization files. Thank you!
    – Mike
    Aug 3, 2015 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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