I am currently translating all of my plugins with loco translate. This is working fine on frontend and in all metaboxes in the backend, but not in the wp-admin menu:
The red circled word should be in german but isn't.
My Custom Post Type:
<?php
function add_ons() {
register_post_type('add_ons',
array(
'labels' => array(
'name' => __( 'Add-Ons', 'add-ons' ),
'singular_name' => __( 'Add-On', 'add-ons' ),
),
'taxonomies' => array( 'add_ons_category' ),
'public' => true,
'has_archive' => true,
'show_ui' => true,
'rewrite' => array(
'slug' => 'add-ons'
),
'supports' => array(
'title',
'editor',
'post-thumbnail',
'custom-fields',
'revisions'
)
)
);
}
add_action('init', 'add_ons');
function add_on_category() {
register_taxonomy( 'add_ons_category', 'add_ons', array(
'label' => __( 'Add-On Category', 'add-ons' ),
'rewrite' => array( 'slug' => 'add-on-category' ),
'show_admin_column' => true,
'hierarchical' => true,
) );
}
add_action( 'init', 'add_on_category', 0 );
The text domain is correct and I have translated the strings in Loco Translate, they are just not showing in the menu. But they are shown anywhere else where they are used.
Any ideas?
I am currently translating all of my plugins with loco translate. This is working fine on frontend and in all metaboxes in the backend, but not in the wp-admin menu:
The red circled word should be in german but isn't.
My Custom Post Type:
<?php
function add_ons() {
register_post_type('add_ons',
array(
'labels' => array(
'name' => __( 'Add-Ons', 'add-ons' ),
'singular_name' => __( 'Add-On', 'add-ons' ),
),
'taxonomies' => array( 'add_ons_category' ),
'public' => true,
'has_archive' => true,
'show_ui' => true,
'rewrite' => array(
'slug' => 'add-ons'
),
'supports' => array(
'title',
'editor',
'post-thumbnail',
'custom-fields',
'revisions'
)
)
);
}
add_action('init', 'add_ons');
function add_on_category() {
register_taxonomy( 'add_ons_category', 'add_ons', array(
'label' => __( 'Add-On Category', 'add-ons' ),
'rewrite' => array( 'slug' => 'add-on-category' ),
'show_admin_column' => true,
'hierarchical' => true,
) );
}
add_action( 'init', 'add_on_category', 0 );
The text domain is correct and I have translated the strings in Loco Translate, they are just not showing in the menu. But they are shown anywhere else where they are used.
Any ideas?
Share Improve this question asked May 20, 2020 at 11:46 toneyttoneyt 416 bronze badges 1- It sounds like it would be best to ask Loco Translate's support team, since it looks like you've set everything up as translatable and you've verified the text-domain is correct. – WebElaine Commented May 20, 2020 at 13:53
1 Answer
Reset to default 1For anyone having the same trouble, I am now using a workaround from the accepted answer on the following question: https://wordpress.stackexchange/a/30723/181214
I am using the solution beyond the "EDIT: Another Option" which is working fine for slugs, names, singular names etc.
function get_labels() {
// return a default slug
if(!defined('WPLANG') || !WPLANG || 'de_DE' == WPLANG) return array('slug' => 'produkt', 'name' => 'Produkte', 'singular_name' => 'Produkt');
$slugs = array(
'en_US' => array('slug' => 'product', 'name' => 'Products', 'singular_name' => 'Product'),
'en_UK' => array('slug' => 'product', 'name' => 'Products', 'singular_name' => 'Product'),
'de_DE' => array('slug' => 'produkt', 'name' => 'Produkte', 'singular_name' => 'Produkt'),
'de_CH' => array('slug' => 'produkt', 'name' => 'Produkte', 'singular_name' => 'Produkt'),
'fr_FR' => array('slug' => 'produit', 'name' => 'Produits', 'singular_name' => 'Produit'),
'es_ES' => array('slug' => 'producto', 'name' => 'Productos', 'singular_name' => 'Producto')
);
return $slugs[WPLANG];
}
function product() {
$labels = get_labels();
register_post_type('product',
array(
'labels' => array(
'name' => $labels['name'],
'singular_name' => $labels['singular_name'],
),
'public' => true,
'has_archive' => true,
'show_ui' => true,
'rewrite' => array(
'slug' => $labels['slug']
),
'show_in_menu' => true,
'supports' => array(
'title',
'post-thumbnail',
)
)
);
}
add_action('init', 'product');
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742285687a4415277.html
评论列表(0条)