[Plugin: qTranslate] Translating custom taxonomy names
-
When editing Post categories, I can easily set their name in multiple languages using qTranslate. qT gives me multiple inputs, one for each language (perfect).
But when editing the names of custom taxonomies, I don’t have the same multi-input option. It’s only one input for the name.
So I tried using quick tags when naming custom taxonomies, to define to the English name, German name, etc. But that didn’t work. The output on the front-end showed the entire input, including the entered quick tags.
How can we manage custom taxonomy names in multiple languages?
-
I’m having the same problem, ?could you find a solution to solve it?
Regards!
Check this out, it worked great for me.
add_action( 'init', 'register_custom_artist' ); function register_custom_artist() { $labels = array( 'name' => _x( 'Artists', 'artist' ), 'singular_name' => _x( 'Artist', 'artist' ), 'add_new' => _x( 'Add New', 'artist' ), 'add_new_item' => _x( 'Add New Artist', 'artist' ), 'edit_item' => _x( 'Edit Artist', 'artist' ), 'new_item' => _x( 'New Artist', 'artist' ), 'view_item' => _x( 'View Artist', 'artist' ), 'search_items' => _x( 'Search Artists', 'artist' ), 'not_found' => _x( 'No artists found', 'artist' ), 'not_found_in_trash' => _x( 'No artists found in Trash', 'artist' ), 'parent_item_colon' => _x( 'Parent Artist:', 'artist' ), 'menu_name' => _x( 'Artists', 'artist' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'description' => 'Artists', 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'), 'taxonomies' => array( 'category', 'post_tag', 'page-category' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => 'route/to/icon.jpg', 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'post' ); register_post_type( 'artist', $args ); }
I think this is what exactly you were looking for. Add it to your theme’s function.php file and voilà!
add_action('your_custom_taxonomy_add_form', 'qtrans_modifyTermFormFor'); add_action('your_custom_taxonomy_edit_form', 'qtrans_modifyTermFormFor');
That works perfectly! Thanks wgarcia!
Good. I’m glad it also worked for you : )
Hi, I’ve the same problem than Brian. I’ve tried to add
add_action(‘your_custom_taxonomy_add_form’, ‘qtrans_modifyTermFormFor’);
add_action(‘your_custom_taxonomy_edit_form’, ‘qtrans_modifyTermFormFor’);to my functions.php file in the theme directory and I’ve added
[:en]Translating[:es]Traducción
on the Portfolio Categories names, but I still don’t have the categories translated. Instead, [:en]Translating[:es]Traducción appears as category on front end.
could you please give me some instructions on how to make this work?
Thanks a lot
PaoloI had the same problem,
just add the code below to your functions.phpadd_filter('the_category', 'multilanguage_category'); if(!function_exists('multilanguage_category')): function multilanguage_category($category_name){ return __($category_name); } endif;
You use the filter which applied at file wp-admin/includes/template.php lines 48 & 196
The above code, it’s about to translate the custom categories name in admin, if you want in your theme, or a plugin to translate you simple use the functions __(), _e()
Hi wpthm,
Would this work for the portfolio categories?
thanks!
pI don’t know,I haven’t use the portfolio plugin, in the admin I believe yes, Try it, and if you have a problem tell us more specifically.
Hello,
I’ve tried to add the above code to the functions.php file and I’ve used the format [:en]Translating[:es]Traducción in the portfolio categories, but they still show up as [:en]Translating[:es]Traducción in the front end.
I actually found this code to add to functions.php which adds a field to the posts (note: not portfolio, which is what I need) categories for the translated version
require_once ( ABSPATH . ‘wp-admin/includes/plugin.php’ );
$lookforqt = ‘qtranslate/qtranslate.php’;
$category_description = category_description();
if ( ! empty( $category_description ) ) {if (is_plugin_active( $lookforqt )) {
_e( ‘<div class=”category-archive-meta-multilingual”>’ . $category_description, ‘qtranslate’ . ‘</div>’ );
} else {echo apply_filters( ‘category_archive_meta’, ‘<div class=”category-archive-meta”>’ . $category_description . ‘</div>’ );
}
}It works perfectly. Would it be easier to modify this code to have also the portfolio categories translated?
Thanks a lot
Paologuys I’m adding in theme function.php file but wthout result
add_action('your_custom_taxonomy_add_form', 'qtrans_modifyTermFormFor'); add_action('your_custom_taxonomy_edit_form', 'qtrans_modifyTermFormFor'); my custom taxonomy is: <?php /** Penguin Framework Module - Portfolio Post Copyright (c) 2012 Activetofocus @url https://penguin.activetofocus.com @package Penguin @version 1.0 **/ class PenguinModulePortfolioPost { public $id = "portfolio"; /** * PenguinModulePortfolioPost */ function PenguinModulePortfolioPost() { add_action( 'init', array($this,'portfolio_register') ); } // Register portfolio function portfolio_register(){ $labels = array( 'name' => _x('Portfolios', 'post type general name','newidea'), 'singular_name' => _x('Portfolios', 'post type singular name','newidea'), 'add_new' => _x('Add New', 'Portfolios','newidea'), 'add_new_item' => __('Add New','newidea'), 'edit_item' => __('Edit Portfolio','newidea'), 'new_item' => __('New Portfolio','newidea'), 'all_items' => __('All Portfolios','newidea'), 'view_item' => __('View Portfolios','newidea'), 'search_items' => __('Search Portfolio','newidea'), 'not_found' => __('No portfolio found','newidea'), 'not_found_in_trash' => __('No portfolio found in Trash','newidea'), 'parent_item_colon' => '', 'menu_name' => 'Portfolios' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug'=>$this->id,'with_front'=>false), 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'thumbnail' ) ); register_post_type($this->id,$args); $this->register_categories(); } //Register Portfolio categories function register_categories(){ $labels = array( 'name' => _x( 'Portfolio Categories', 'taxonomy general name' ,'newidea'), 'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ,'newidea'), 'search_items' => __( 'Search Portfolio Categories' ,'newidea'), 'all_items' => __( 'All Portfolio Categories' ,'newidea'), 'parent_item' => __( 'Parent Category' ,'newidea'), 'parent_item_colon' => __( 'Parent Category:' ,'newidea'), 'edit_item' => __( 'Edit Portfolio Category' ,'newidea'), 'update_item' => __( 'Update Portfolio Category' ,'newidea'), 'add_new_item' => __( 'Add Portfolio Category' ,'newidea'), 'new_item_name' => __( 'New Portfolio Category' ,'newidea'), 'menu_name' => __( 'Portfolio Categories' ,'newidea') ); register_taxonomy($this->id.'_categories',array($this->id), array( 'hierarchical' => true, 'labels' => $labels, 'label_sing' => __( 'Portfolio Category','newidea'), 'public' => true, 'show_in_nav_menus' => true, )); } } ?>
[Please post code or markup between backticks or use the code button. Or better still – use a pastebin. Your posted code may now have been permanently damaged/corrupted by the forum’s parser.]
what should be written, please help
in admin everything is ok but in front end it is not showing portfolio item translation … ??
any help .. please
Just add this code in theme function.php file to to automatically detect all the taxonomies.
function qtranslate_edit_taxonomies(){ $args=array( 'public' => true , '_builtin' => false ); $output = 'object'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies = get_taxonomies($args,$output,$operator); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor'); add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor'); } } } add_action('admin_init', 'qtranslate_edit_taxonomies');
- The topic ‘[Plugin: qTranslate] Translating custom taxonomy names’ is closed to new replies.