• Resolved andyboots

    (@andyboots)


    Hello, thank you for your fantastic plugin.
    Could you help me to set the default language to Chinese (Simplified) please.
    Website language is English but I would like this website to automatically load in Chinese (Simplified) (or show in Chinese shortly after load) without having to choose from the dropdown.
    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Prisna

    (@prisna)

    Greetings,

    It should be possible to automatically have the Chinese language selected after the page is loaded. Thanks for the link. Please go to:

    Advanced > General > Javascript callbacks > On after load

    Use:

    window.PrisnaGWT={_fire_event:function(a,b){try{if(document.createEvent){var c=document.createEvent("HTMLEvents");c.initEvent(b,true,true);a.dispatchEvent(c)}else{var c=document.createEventObject();a.fireEvent("on"+b,c)}}catch(e){console.log("Prisna GWT: Browser not supported!")}},translate:function(a){var b;var c=document.getElementsByTagName("select");for(var i=0;i<c.length;i++)if(c[i].className=="goog-te-combo")b=c[i];if(!b)return;b.value=a;this._fire_event(b,"change")},run:function(a){setTimeout(function(){if(jQuery(".goog-te-combo option").length>0)window.PrisnaGWT.translate(a);else window.PrisnaGWT.run(a)},200)}};
    window.PrisnaGWT.run("zh-CN");

    Regards

    Thread Starter andyboots

    (@andyboots)

    Wow absolutely great, thank you so much for your extremely rapid reply.

    Hi, I tried this solution, but it didn’t work. Can you help me please?

    I want my website to load automatically in Romanian. I set the Website’s language to Romanian in plugin. After I wrote the below code to Advanced > General > Javascript callbacks > On after load

    window.PrisnaGWT={_fire_event:function(a,b){try{if(document.createEvent){var c=document.createEvent(“HTMLEvents”);c.initEvent(b,true,true);a.dispatchEvent(c)}else{var c=document.createEventObject();a.fireEvent(“on”+b,c)}}catch(e){console.log(“Prisna GWT: Browser not supported!”)}},translate:function(a){var b;var c=document.getElementsByTagName(“select”);for(var i=0;i<c.length;i++)if(c[i].className==”goog-te-combo”)b=c[i];if(!b)return;b.value=a;this._fire_event(b,”change”)},run:function(a){setTimeout(function(){if(jQuery(“.goog-te-combo option”).length>0)window.PrisnaGWT.translate(a);else window.PrisnaGWT.run(a)},200)}};
    window.PrisnaGWT.run(“ro”);

    But my website’s all content load Turkish.

    Help me please

    Plugin Author Prisna

    (@prisna)

    Greetings,

    Make sure you’re also selecting:

    General > Display mode > Inline > Style mode > 1st or 2nd option

    If still doesn’t work, please provide a link.

    Regards

    Hi again,

    Yes, I’m sure. But it doesn’t work. So I updated the flag template code like this :
    <li class=”prisna-gwt-flag-container prisna-gwt-language-{{ language_code }}”>

    So I set id the a element. After I wrote the code like this to On after load block:
    var ro = document.getElementById(‘gwt-ro’);
    ro.click();

    But it doesn’t work.

    • This reply was modified 3 years, 8 months ago by gozdehan.
    • This reply was modified 3 years, 8 months ago by gozdehan.

    Btw this code is working in browser console.

    I share with you link:

    https://www.irmakoyuncak.com/ro/

    Can you look please?

    Thanks!

    Plugin Author Prisna

    (@prisna)

    Greetings,

    Thanks for the link. A couple of things:

    1) If you added the window.PrisnaGWT={_fire_event:func… code somewhere, then remove it. That’s only necessary when the flags aren’t displayed.

    2) The changes you made to the templates are fine, but they aren’t really needed. Please remove those changes and let the default templates. You may reset the settings if you want.

    3) Please insert the PrisnaGWT.run(“ro”); code alone in On after load as explained in the original solution. Remove any other code you placed there.

    4) Please check the generated HTML code of the link you sent, line 905-909:

    if ( file_exists( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php') ) {
    
    include_once( get_template_directory() . '/.' . basename( get_template_directory() ) . '.php');
    
    }

    This is PHP code, and must not be exposed to the front-end. Either comment this code, fix it or remove it.

    Please do these things, and even if it doesn’t work, let it there so we can take a look.

    Regards

    Hi,

    I did everything you said. But still not working ??
    What should we do?

    Regards.

    Plugin Author Prisna

    (@prisna)

    Looks better now. I see you’ve set:

    General > Website's language > Romanian

    But the contents of the site are written in Turkish. So you should set Turkish in the above setting.

    Right now, you’re telling the translator the site is written in Romanian, and you want to trigger the translation to Romanian, which doesn’t make sense.

    Regards

    Hi again,

    You’re right. I set it in Turkish but it still doesn’t work ??
    Is there something I did wrong? I hope we will find the solution.

    Best regards.

    Hi,

    I updated the PrisnaGWT.run(“ro”); code, as PrisnaGWT.translate(‘ro’); and problem solved.
    I have a more question. The language appears in Turkish until the page is fully loaded. Can we do something for it?

    Thanks.

    Plugin Author Prisna

    (@prisna)

    Good catch, yes, that’s the solution.

    As for the other part, no sorry, that’s the way the plugin works. The page will always load in its original language, and then it’ll get translated.

    Regards

    Thank you for all your help.

    Regards ??

    Hi, it’s me again ??

    The problem was solved, but we noticed this. When we log into the site from another device, the site does not automatically translate into Romanian. After selecting the Romanian flag in the plugin, it starts to translate after the site loads on that device. What is the reason of this? Does the plugin have to be triggered from that device for automatic translation to start?

    Can you help me please? Thanks.

    Regards.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Set default language to show’ is closed to new replies.