Skip Navigation

[Resolved] Content Template for bilingual website

This support ticket is created 9 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Tagged: 

This topic contains 6 replies, has 3 voices.

Last updated by Qutb 9 years, 7 months ago.

Assigned support staff: Bigul.

Author
Posts
#58783

We use qTranslate to produce our bilingual website..

Now, I need to attache a Content Template to a post type, but with the ability to switch between the two languages we support. I used the 2 tags (I know) for qTranslate: <!--:en--><!--:--> and [:en] but Views neglects both of them and just displays the two languages contents together in the same layout.

Is there any way/trick or another plugin to workaround this incompatibility issue between qTranslate and Views?

One of the plugins I tried is "Custom Content Widget" http://wordpress.org/extend/plugins/custom-post-widget/ which is perfectly compatible with qTranslate. I put a shortcode produced by this plugin in a Content Template attached to a post. But I got then this error message:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/......./wp-content/plugins/wp-views/embedded/inc/views-templates/wpv-template.class.php on line 0

Does this way seem promising or does this message mean it's a dead-end here?

#59288

Bigul
Supporter

Hi Qutab,

qTranslate is not fully compatible to Views. Can you please check this thread for more details https://toolset.com/forums/topic/using-qtranslate-with-types/ .

Please recheck your custom code logic.

---

With Regards

Bigul

#59314

The thread you attached is about Types not Views.. So I'll appreciate more detailed advise how to make use out of it in this issue, as I, must say, have zero coding skills.

What you said is that Views is not "fully" compatible with qTranslate, so to which level I can find "some" compatibility between them?

#60041

Juan
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Qutb.

I'm working with Bigul on this issue and I think I found the problem and the solution. First, let me explain what is going on here.

By the way Content Templates are constructed, qTranslate Quicktags do not work there. So I would recommend you to use normal tags in Content Templates. I'm using the names as described here:
hidden link
Now, using normal tags, qTranslate assumes that your content is being passed through a GetText call to render the appropriate language. But inside Content Templates, this is not happening.

But we can make it happen.

My solution is as follows: create a custom shortcode that will take everything inside it and pass it through a GetText call before output. I am going to share here with you the shortcode code and an example for you to test it.

Please place this code in your functions.php file

function renderqtinsidevt_func( $atts, $cont = null ){
 return __($cont);
}
add_shortcode( 'renderqtinsidevt', 'renderqtinsidevt_func' );

Now, open your Content Template and add the following, replacing the :en and :es calls to whatever your languages are:

[renderqtinsidevt]<!--:en-->Hello<!--:--><!--:es-->Hola<!--:-->[/renderqtinsidevt]

It should work. Now, every time you need to show content in different languages inside a Content Template, just wrap it inside your new shortcode and use normal qTranslate tags.

Hope it helps.

let us know if this solves your issue or if you need further help with this.

Regards,
Juan de Paco

#60129

Dear Juan,

First I must thank you for your solution, which works fine.. but to a certain limit.

The fatal error has gone, and the content is displayed due to its language, but the problem now is that the view template displays the shortcodes, that are within the content, as a normal text without rendering their values..

I'll paste here a sample of the content the view template should deal with:

[renderqtinsidevt]
<!--:en-->
[wpv-if evaluate="'[wpv-post-logged]' = 1"]
[cred-delete-post-link action="trash" text="Trash"] | [cred-link-form form="Edit Document" text="Edit" target="_self"]
[/wpv-if]

<table class="sample"><colgroup> <col width="25%" /> <col width="75%" /></colgroup>
<tbody>

[wpv-if description_en="wpcf-description_en" evaluate="!empty($description_en)"]
<tr>
<td style="padding-left: 10px; padding-right: 10px; padding-top: 5px; background-color: #cdcdcd;" valign="top"><span style="color: #000000;">Description</span></td>
<td style="padding-left: 10px; padding-right: 10px; padding-top: 5px; background-color: #d0dbf4;" valign="top"><span style="color: #000000;">[types field="description_en" class="" style=""][/types]</span></td>
</tr>
[/wpv-if]
</tbody>
</table>
<!--:-->
<!--:ar-->
[wpv-if evaluate="'[wpv-post-logged]' = 1"]
[cred-delete-post-link action="trash" text="حذ?"] | [cred-link-form form="Edit Document" text="تحرير" target="_self"]
[/wpv-if]
<table class="sample"><colgroup> <col width="25%" /> <col width="75%" /></colgroup>
<tbody>
[wpv-if description_ar="wpcf-description_ar" evaluate="!empty($description_ar)"]
<tr>
<td style="padding-left: 10px; padding-right: 10px; padding-top: 5px; background-color: #cdcdcd; text-align: right;" valign="top"><span style="color: #000000;">ملخص</span></td>
<td style="padding-left: 10px; padding-right: 10px; padding-top: 5px; background-color: #d0dbf4; text-align: right;" valign="top"><span style="color: #000000;">[types field="description_ar" class="" style=""][/types]</span></td>
</tr>
[/wpv-if]
</tbody>
</table>
<!--:-->
[/renderqtinsidevt]

As you'd see, I already put your shortcodes. All what I need is to make the CRED and Types shortcodes, which are included in the content, functions as it's expected.

Again, many thanks for your help 🙂

#60331

Juan
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Qutb.

Yes, using the first solution I gave you the Types and CRED shortcodes inside your new shortcode do not work, but there is an easy solution for that. I just tested and it's working fine.

All we need to do is apply the_content filters to the output of our new shortcode. To do so, you need to edit the renderqtinsidevt_func() function to be like this:

function renderqtinvt_func( $atts, $cont = null ){
 return apply_filters('the_content', __($cont));
}

Let me know if this solves your issue and if I can help you with anything else.

Regards,
Juan de Paco

#60630

Brilliant!! I owe you one 🙂