• Resolved tintix

    (@tintix)


    Hi. The parts which are loaded by AJAX in this plugin do not detect the current language. So I did a little hack in plugin’s JS that passes the language code in AJAX calls.
    Now it partially works only by repeated AJAX call. E.g. when I switch the language on my site – the AJAX loads content in previous language. When I choose another category from question list to reload AJAX content, it loads it in correct language. But that still works only in gettext calls, where translations are available. Parts which are translated by qtranslate e.g. category names are loaded in site’s default language.

    https://www.ads-software.com/plugins/dw-question-answer/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tintix

    (@tintix)

    Well, I solved my problem. The untranslated parts were custom taxonomy parts – in this case the question categories. Seems like this is a mqtranslarte bug that prevents correct term translation during AJAX call. I fixed it using this snippet added to my theme’s functions.php

    if (defined('DOING_AJAX') && DOING_AJAX) {
        add_filter('wp_get_object_terms', 'dwqa_question_category_ajax_filter');
    }
    
    function dwqa_question_category_ajax_filter($terms) {
        global $q_config;
        foreach ($terms as $term) {
            if ($term->taxonomy == 'dwqa-question_category' && isset($q_config['term_name'][$term->name][$q_config['language']])) {
                $term->name = $q_config['term_name'][$term->name][$q_config['language']];
            }
        }
        return $terms;
    }

    THANK YOU!!!!!!!!!!!!!!!!!
    Really really thank you!

    Hi! Can you help me? – AJAX serach load content from all post in the site, but I need search only in category DW Q&A https://allpets1.com/dwqa-questions/

    What the problem do you think?

    Thanks!

    Do you have access to your database? Maybe through PHPMyAdmin? If so search for the table taxonomy and look for the exact name of DW Q&A category name. Otherwise you can grab the name when you are in the page where you add/edit DW Q&A categories.
    When you have that, for tintix was dwqa-question_category, just replace in the tintix’s code.

    Hope it helps

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Qtranslate/mQtranslate support’ is closed to new replies.