• Resolved sottise

    (@sottise)


    I have already asked for help regarding this problem, but as it seems not resolved yet, I’m asking for help again.

    I am using both: “language menu” in my header + my own picture in the sidebar. The language menu works well.
    I was using the qtranslate plugin before, and my own button / picture code was working great as well.

    When I’ve switched to qtranslate-x plugin, it stopped working.
    I mean, switching from Fr (the default language) to En works, but it doesn’t works from EN to FR.

    When I un-check: “Hide URL language information for default language. ” it works! But then I can’t access to my wp-admin!

    Could someone help me with this? Or maybe I could use another code?

    Here is the code :

    <?php if(qtranxf_getLanguage()=='fr'): ?>
    <div class="langSWITCHER_EN">
    <a class="languen" href="<?php echo getUrlInTargetLanguage("en"); ?>" >Translate</a>
    </div>
    
    <?php endif; ?>
    
    <?php if(qtranxf_getLanguage()=='en'): ?>
    <div class="langSWITCHER_FR">
    
    <a class="langufr" href="<?php echo getUrlInTargetLanguage("fr"); ?>" >Traduire</a>
    </div>
    
    <?php endif; ?>

    Notice also that I was previously using the qtrans_ code, with the Compatibility Functions enabled, but the problem was the same…

    See link and the sidebar image “Je parle franΓ§ais” / “I speak English”

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Gunu

    (@grafcom)

    Hello again,

    Side bar – can you not use the widget? – Appearance – widgets – Primary Sidebar – qTranslate Language Chooser –

    Thread Starter sottise

    (@sottise)

    Hello and thanks again for your help Gunu! πŸ™‚

    Mmmmh, yes, I could, but I would like to use the picture that you see in the sidebar.
    I tried to change the CSS code in the qTranslate Language Chooser widget but it was really tricky…

    Plugin Author Gunu

    (@grafcom)

    @sottise,

    No idea, but

    <a class="langufr" href="<?php echo getUrlInTargetLanguage("fr"); ?>" >Traduire</a>

    Try change to this:

    <a class="langufr" href="<?php echo getUrlInTargetLanguage(""); ?>" >Traduire</a>

    or something because /fr is disabled ??? eventually we will get there πŸ™‚

    Thread Starter sottise

    (@sottise)

    Clever! But unfortunately does not work either… nice try anyway!

    Maybe we should replace <?php echo getUrlInTargetLanguage by something else but I know nothing about php :/

    And yes, it was working well with the /fr enabled, but since I had problems with the admin connexion…

    Plugin Author Gunu

    (@grafcom)

    @sottise,

    we will ask John πŸ™‚

    Thread Starter sottise

    (@sottise)

    Thanks a bunch Gunu for your concern and your help!!
    Hoping that John will find out a solution πŸ™‚

    Plugin Author Gunu

    (@grafcom)

    this could you also try first:

    change settings – General –
    Wordpress adress URL: popandsoda.com/blog
    and Site adress URL: popandsoda.com/blog

    please ensure that your code works under popandsoda.com/blog as main site so we can see if that redirect has influence and if the code is standard ok.

    Plugin Author John Clause

    (@johnclause)

    Where is the code of function getUrlInTargetLanguage('en')? I never saw this function anywhere. Is it a part of theme? Can you try instead qtranxf_get_url_for_language('', 'en', true)? Do you use “QTranslate Slug”? It is currently not compatible with -X.

    Plugin Author John Clause

    (@johnclause)

    Other solution, which may work without changing the code, disable cookie via option “Cookie Settings”. Something else may get broken, but knowing that it worked under qTranslate before, it might be ok, unless you start using some other sophisticated enough plugins like Woocommerce in the future.

    Thread Starter sottise

    (@sottise)

    @john Clause:

    Oups, yes, sorry, indeed, there is a function :

    // Permalink in current language
    function getUrlInTargetLanguage($targetLang){
        global $qtranslate_slug;
        return $qtranslate_slug->get_current_url($targetLang);
    }

    which is apparently using Qtranslate Slug yes.

    No, It’s a code that I’ve found somewhere when I was using mqtranslate.

    Thread Starter sottise

    (@sottise)

    yeay, apparently it works fine now with the code you gave me!!

    This is how it looks now:

    <?php if(qtranxf_getLanguage()=='fr'): ?>
    
    <div class="langSWITCHER_EN">
    <a class="languen" href="<?php echo qtranxf_get_url_for_language('', 'en', true); ?>" >Translate</a>
    </div>
    
    <?php endif; ?>
    
    <?php if(qtranxf_getLanguage()=='en'): ?>
    <div class="langSWITCHER_FR">
    
    <a class="langufr" href="<?php echo qtranxf_get_url_for_language('', 'fr', true); ?>" >Traduire</a>
    </div>
    
    <?php endif; ?>

    I guess the function code is obsolete now?
    Thanks very much to both of you! Great support πŸ™‚

    PS: I didn’t touched to the cookies option you mentioned.

    Plugin Author Gunu

    (@grafcom)

    @sottise,

    Great ! I mark this post as Resolved.

    Best

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Language switching button doesn't work’ is closed to new replies.