Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Im currently trying to make my backend work with multiple languages. Im using qTranslate as my translation plugin.

So far I have accomplished a custom option page with multi-language support. When you click on a different language (in qTranslate on the sidebar) you will get a new options page with prepared option-variables

show(option_textarea) -> 'english backend' -> show(option_textarea_en)
(saving under the same variable possible)

So, if I use one of the options in my template im just accessing the option with the current active language

give(option_logo) -> 'german page viewing' -> return option_logo_de

This also works on the widget-page-side. EXCEPT, when I'm switching my current language in the backend each widget gets the status 'unused' and I have to manually put in the widgets again. They don't exist for the current active language and are not faved. So in general I can only set widgets for one language at a time. The widgets from the other language i have set are dropped then. How can I deactivate this behaviour?

What I need is a fixed widget-editing system that works the same way as my options. Maybe there is a workaround for this problem?

Thanks in advance.

share|improve this question
    
ehm... everyone sleeping or is it the awesome weekend? ;) –  proxylittle Aug 28 '11 at 15:19
add comment

2 Answers

up vote 1 down vote accepted

I don't know how qTraslate works, but you can pass filters to Widget Logic , you basically duplicate each widget, one for each language. I have used this technique with WPML to show widgets in separate languages that can sometimes be difficult ( such as when they make direct DB queries).

share|improve this answer
    
i'll accept this as it seems to be the only way to do it. –  proxylittle Aug 23 '12 at 13:00
    
I want to add I have had some problems with Widget Logic recently and found another great plugin called wordpress.org/extend/plugins/display-widgets that works well. –  Wyck Aug 23 '12 at 17:22
add comment

As Wyck points out, that's the easiest way.

I have the following function in my functions.php and use it to filter a bunch of duplicated widgets, one for each language, e.g.: is_lingo('en'), is_lingo('pt'), etc...

function is_lingo( $what ) 
{
    if ( !function_exists('qtrans_getLanguage') )
        return false;

    $lingo = qtrans_getLanguage(); 

    if( $what == $lingo ) 
        return true;

    return false;
}
share|improve this answer
    
upvoted for the nice code, thanks –  proxylittle Aug 23 '12 at 13:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.