• Resolved marjungle

    (@marjungle)


    Hi, I did a translation of the plugin into Spanish, renamed the files correctly and it works well. I don’t have any problem with the plugin translation.

    But I have a problem with the kind of posts that the plugin is loading. It is loading the default language posts for both English and Spanish. I am using Polylang to have my site in two languages. I have posts in English and posts in Spanish, and all of them load correctly at the selected language, anywhere in the site, except in the plugin.

    If you are reading in English, the plugin appears in English and the text of posts in English too. But if you move to Spanish, the whole site loads in Spanish, the plugin gets translated into Spanish too, but its content (posts) load in English.

    My WordPress theme is Leeway.

    Thanks in advance.

    Mar

    https://www.ads-software.com/plugins/wp-tab-widget/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author MyThemeShop

    (@mythemeshop)

    Hi,
    The widget uses AJAX technique to load the posts, separately from the rest of the page, and that might be causing the issue.

    After some quick Googling, I found that a possible solution is to tell Polylang the needed language in the AJAX call, like so: admin-ajax.php?lang=code

    You should be able to change it by editing this part in wp-tab-widget.php file:

    wp_localize_script( 'wpt_widget', 'wpt',
    				array( 'ajax_url' => admin_url( 'admin-ajax.php' ))
    			);

    Change it to this:

    wp_localize_script( 'wpt_widget', 'wpt',
    				array( 'ajax_url' => admin_url( 'admin-ajax.php?lang=YOURLANGCODE' ))
    			);

    However, this will make it load the posts in the other language, even when looking at the english version of the site. To adjust it automatically, you’ll need some more advanced code, something like this:

    $pl_lang = function_exists( 'pll_current_language' ) ? pll_current_language( 'locale' ) : '';
    wp_localize_script( 'wpt_widget', 'wpt',
    				array( 'ajax_url' => admin_url( 'admin-ajax.php?lang='.$pl_lang ))
    			);

    We did not test this, and, as this is more of a Polylang-related question, please try asking in their support forums if doesn’t work as expected.
    Thank you.

    Thread Starter marjungle

    (@marjungle)

    It works! ??

    I added the advanced code to wp-tab-widget.php right after the first code that you describe, that I haven’t altered.

    It works fine now. Thank you so much!!!

    Plugin Author MyThemeShop

    (@mythemeshop)

    Hello,

    Glad that helped.

    We would appreciate if you can share your experience with the WordPress’s community by leaving a feedback:
    https://www.ads-software.com/support/view/plugin-reviews/wp-tab-widget?filter=5

    Please let us know if you need any assistance. We are here to help.

    Thank you.

    Thread Starter marjungle

    (@marjungle)

    Absolutely. Review already posted. A pity I can’t show you how great it looks in our site, but it does.

    Thank you again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Loading wrong language posts’ is closed to new replies.