This is my setup:
- WordPress: 3.4.2
- qTranslate: 2.5.32
- Advanced Custom Field: 3.5.1
- i’ve also installed qTranslate extension: 1.1.1 but I don’t know how/if it works…
How can I have a multilanguage WYSIWYG custom field edit area with tabs for each language as the main text editor?
Thanks!
Stefano
1 Answer
Tip 1: do not use qtranslate. I’ve used for years and now I can say that never been money better spent than those for WPML, specially if compared to the work needed to solve problems qT brings.
Also consider that WPML is compatible with a huge number of plugins and themes, in years I used qTranslate never found a theme or a plugin compatible with it.
Tip 2: Regardless of which plugin you use, qT or WPML, to do what you want, require to write an entire and complex plugin.
A workaroud is to use different fields for different languages.
E.g. have the field ‘size’ for english and field ‘taglia’ for italian, and so on. Than in template file retrieve current language and print right field using a switch
statement.
Following code is just an example
function get_localized_size($postid) {
if ( ! intval($postid) ) {
global $post;
if ( empty($post) || ! is_object($post) || ! isset($post->ID) ) return;
$postid = $post->ID;
}
$currlang = qtrans_getLanguage() ? : 'en'; // <-- qtranslate
// $currlang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : 'en'; // <-- WPML
switch ( strtolower($currlang) ) {
case 'es' :
$field = 'tamano';
break;
case 'it' :
$field = 'taglia';
break;
case 'fr' :
$field = 'taille';
break;
case 'en' :
default :
$field = 'size';
break;
}
$size = get_post_meta($postid, $field, true);
return sprintf( __('The size is: %s', YOURTEXTDOMAIN ), $size );
}
Than in the loop:
...
the_post();
...
echo get_localized_size(); // pass post ID as argument when out of the loop
...