Support » Plugin: Polylang » How to notify users that there are no translation for this post/page/category

Viewing 4 replies - 1 through 4 (of 4 total)
  • I think you need to modify the loop in your theme.

    Chouby provides a snippet here in the documentation, and there is a bit more information in this support topic.

    However I think it could be a good feature to request for a later version of Polylang. I suggested something similar to trap all of these error conditions:

    Since Polylang knows which language the user requested, maybe an error message in their language? You could provide a list of the languages available for that page, and even an online translation? Maybe:
    Sorry, the content you requested is not available in XXX language. You may choose from these currently available languages or try a machine-translated version.

    What do you think? Maybe some people would still prefer an option to direct visitors back to the homepage instead.

    Thread Starter weeix

    (@weeix)

    Yeah I think that would be great too.

    Not sure how to adapt the snippet for my case (I just wan’t to deal with the link)

    I’m trying to figure out how to add some class to that link – something like class="pll-no-translation" – so I could use jQuery to deal with it. But with my current knowledge about WP & PHP, I’m not sure is that even possible lol

    Plugin Author Chouby

    (@chouby)

    You can send your visitor to a custom error page. You can add something like this in a custom plugin:

    add_filter('pll_the_language_link', 'no_translation_link', 10, 2);
    function no_translation_link($url, $slug) {
    	if ($url === null) {
    		if ($slug == 'en')
    			$url = get_permalink(x); // replace x by the id of the page you want to link to
    		elseif ($slug == 'fr')
    			$url = get_permalink(y); // replace y ...
    	}
    	return $url;
    }

    I will add a class “no-translation” in v1.0

    Thread Starter weeix

    (@weeix)

    Thanks, that’s very nice of you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to notify users that there are no translation for this post/page/category’ is closed to new replies.