WordPress.org

Ready to get started?Download WordPress

Forums

qTranslate slug with widget
untranslated content link (2 posts)

  1. whoopcg
    Member
    Posted 2 years ago #

    Hi there. Thanks for the plugin.
    I don't know if the problem is from qtranslate itself or from this plugin but I will explain myself.

    When content is not available for a language, a message shows, wich is ok.
    The thing is, for example, I'm in "http://www.test.com/es/noticias/" and have a link to a post. When I use the link, the message shows, with the available languages to choose. But the links are wrong.

    It redirects me to:
    . http://www.test.com/en/noticias - but it should be http://www.test.com/en/news.
    It preserves the page name where I am, just adds the language before.

    Can anyone help?

    http://wordpress.org/extend/plugins/qtranslate-slug-with-widget/

  2. voivon
    Member
    Posted 1 year ago #

    Hello,

    I'm using Qtranslate slug (http://wordpress.org/extend/plugins/qtranslate-slug/) and I've got the same problem, this is how I fixed it:

    I noticed that links in the language widget selector were always working right so I decided to simply replace the links in the error message with these ones, using jQuery...

    Edit /wp-content/plugins/qtranslate/qtranslate_core.php (this one is used by the error message) and add an id to the link:

    $language_list = "<a href=\"".qtrans_convertURL('', $language)."\">".$q_config['language_name'][$language]."</a>".$language_list;

    Let's say erren or erres (err$language) depending on the language:

    $language_list = "<a id="id='err$language'" href=\"".qtrans_convertURL('', $language)."\">".$q_config['language_name'][$language]."</a>".$language_list;

    Now do the same for /wp-content/plugins/qtranslate/qtranslate_core.php (this one is used by the widget) for this line:

    echo "<li$item_class><a href=\"$url\" hreflang=\"$lang\"$link_class>$link_content</a></li>" . PHP_EOL;

    Let's say widen or wides (wid$lang):

    echo "<li$item_class><a id=\"wid$lang\" href=\"$url\" hreflang=\"$lang\"$link_class>$link_content</a></li>" . PHP_EOL;

    Now go to your theme footer and add the jQuery workaround juste before the </body>, ie for english links:

    <script type="text/javascript">
    jQuery(document).ready(function() {
    
    if (jQuery('a#erren').length) {
    var widen = jQuery("a#widen").attr('href');
    jQuery("a#erren").attr("href", widen);
    }
        });
    </script>

    You can of course improve the script and use dynamic language tags : wid$tag, err$tag

    Hope this helps

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic