I'm trying to add multi-lingual support to my Types through qTranslate but I'm having trouble with implementing the shortcode in a View. I've tried adding the [:en]-style shortcode to both the view (surrounding the Types field shortcode) and within the Types field itself.
The closest source of info I've found was https://toolset.com/forums/topic/types-and-qtranslate/ but there's no mention of how the solution was found.
Dear Joff,
There was no solution mentioned in that thread, just the fact that WYSIWYG fields wont work with qtranslate. Can you manage without them or do you need them?
Regards,
Caridad
Hi Caridad, I really do need them in this instance I'm afraid. The fields I'm using are all single line so I had hoped that qTranslate would work one way or another, either with the qTranslate shortcode within the field itself or as part of the View template but neither approach seem to work.
Dear Jeff,
QTranslate will only modify the title and the content for you to input the different languages. You can have multilingual fields by using QTranslate special notation, for single line fields it has to work:
<!--:es-->Spanish Name<!--:--><!--:en-->English Name<!--:-->
Later, to print the value of this field in a template file you have to use the __() so that QTranslate gets a chance to filter it:
<?php echo __(types_render_field('buildingname', array())); ?>
Please let me know if there is anything else that I can assist you with.
Regards,
Caridad
Hi Caridad, thanks for that but is there a way to print the value of the fields within the View/Content Template?
Dear Joff,
Yes, with the types shortcode:
[types field="buildingname"][/types]
To run all these strings through the QTranslate filter you might need to add some code to functions.php in your theme:
add_filter('wpcf_fields_value_display', '__');
Please let me know if there is anything else that I can assist you with.
Regards,
Caridad
Hi Caridad, many thanks the filter has resolved my issue.
For reference if anyone else is trying to achieve the same, use the filter above with the Types special notation, e.g.
<!--:es-->Spanish Name<!--:--><!--:en-->English Name<!--:-->