qTranslate-Team / qtranslate-x

Wordpress plugin: Adds user-friendly and database-friendly multilingual content management and translation support.
http://qtranslatexteam.wordpress.com/about/
GNU General Public License v3.0
206 stars 149 forks source link

Pretty Links Lite 404 error when using qtranslate-x language redirect #402

Closed artouiros closed 8 years ago

artouiros commented 8 years ago

Hello, I am using Pretty Links Lite plugin and qtranslate-x. Let's say I made a link http://example.com/go-to-external-site-321 I have language redirect enabled in qtranslate-x and when trying to access http://example.com/go-to-external-site-321 it redirects to http://example.com/[langcode]/go-to-external-site-321 and gives 404 error because there is no page go-to-external-site-321 under [langcode]. Is is any way to support Pretty Links Lite plugin?

This is what I tried:

  1. Making pretty links for every language (which is very annoying and hard)
  2. Tried to add an if rule in qtranslate-core.php :
if (strpos($url_orig, 'go-to') == false) {
$target = apply_filters('qtranslate_language_detect_redirect', $url_lang, $url_orig, $url_info);
} else {
// tried this after readin your comments, that this will prevent language redirect 
//and it prevents it but my pretty link doesn't go to external site, still gives a 404 error.
$target = false;
}

btw this is a very bad try, but it was frist that came to my head.

johnclause commented 8 years ago

This problem is solved by creating additional links like http://example.com/[langcode]/go-to-external-site-321 for each language: http://qtranslate-x.com/support/index.php?topic=362

2 The solution must be for all users of Pretty links, not only for go-to. You can make a separate plugin, using filter 'qtranslate_language_detect_redirect', if you wish. The biggest problem is how to distinct pretty link in a general way?

I think #1 is a good enough solution.Yes, it is annoying, but how many pretty links do you make? I would think it is rather occasional, is not it? If you create them programmatically, then it is not a problem to also add links per all languages.

If you end up doing plugin, I think the correct way would be to look into the code of Pretty Links and see how to redirect language-encoded url to the same target too. I would think that language-encoded URLs for the same pretty links should be allowable on a multilingual site. Users may even try to type them in manually thinking that they will get a different language there.

I hope plugin Pretty Links has some filters to make it possible to automate forwarding language-encoded URLs. It should be done there, not in qtx. For example you may get a language-neutral url, before passing it yo Pretty Link code, whatever it is. Or, if they do it via rewrite rules, then during the saving a pretty link, you may add rules for each language too. Anyway this integration plugin should work with Pretty Link's code.

Besides, some people may wish to redirect language-encoded urls to different external URLs, if that target site is multilingual too, so making links for each language is the most general way. You may think about how to make it easier, for example using LSB? This can be probably achieved with .json file: https://qtranslatexteam.wordpress.com/integration/ and then some manipulation of saving values are needed anyway at Pretty Link's side.

We do not have resources to work on such integration plugin. The relevant ideas, which we can provide, are already listed here. If you end up writing this plugin, please, follow the naming convention.

Thanks a lot for sharing the ideas with us, and good luck to you with your further development!