WordPress.org

Forums

mLanguage
Optional mlang-menu (2 posts)

  1. mayeulk
    Member
    Posted 3 years ago #

    Hi,
    I have a blog for which only a few posts are translated in several languages. I want to display the mlang-menu only on posts with contents in several languages, and only with the relevant languages.
    It somehow works if I put this in the post itself (html view):

    <script type="text/javascript" src="http://localhost/wordpress/wp-content/plugins/mlanguage/mlanguage.js?ver=3.0.5"></script>
    <a class="mlang-menu-link" href="/" data-lang="en">
    <img class="mlang-menu-image" style="outline: medium none;" src="http://localhost/wordpress/wp-content/plugins/mlanguage/img/den.png" alt="English" />
    </a>
    <a class="mlang-menu-link mlang-active" href="/" data-lang="fr">
    <img class="mlang-menu-image" style="outline: medium none;" src="http://localhost/wordpress/wp-content/plugins/mlanguage/img/fr.png" alt="fran├žais" />
    </a>

    HOWEVER, when you first go to the web site, if you click very rapidly to the language button, it goes to the root page of the website (here, to: http://localhost/).
    Maybe it is because the mlanguage.js is not loaded yet.
    If you wait or have already loaded mlanguage.js, then it works (until you clear the cache).
    Any hint on how to solve this?
    Thanks!
    PS: a bonus would be to have a short code instead of the above html code.

    http://wordpress.org/extend/plugins/mlanguage/

  2. mayeulk
    Member
    Posted 3 years ago #

    Hi,
    Putting an anchor as the destination of the href somehow works (flag is inneffective until js is loaded).

    <script type="text/javascript" src="http://localhost/wordpress/wp-content/plugins/mlanguage/mlanguage.js?ver=3.0.5"></script>
    
    <a data-lang="en" href="#change_language" class="mlang-menu-link"><img alt="English" src="http://localhost/wordpress/wp-content/plugins/mlanguage/img/den.png" style="outline: medium none;" class="mlang-menu-image"/></a>  <a data-lang="fr" href="#change_language" class="mlang-menu-link mlang-active"><img alt="fran├žais" src="http://localhost/wordpress/wp-content/plugins/mlanguage/img/fr.png" style="outline: medium none;" class="mlang-menu-image"/></a>

    However, I needed to disable to disable visual editor to avoid WP to strip the <script> tag. I solved this installing the "Enhanced Text Widget" plugin and putting the <script> in such a text widget.

    (Note: I do not want to modify the templates)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • mLanguage
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags