I have a language menu such as this (it switches the current page to another language):
- path = current_page.path.split('/')[1..-1].join('/')
%ul{ role: 'langmenu'}
-if I18n.locale != :en
%li
=link_to 'English', "/en/#{path}"
-if I18n.locale != :sr
%li
=link_to 'Serbian', "/sr/#{path}"
I want to show the link to the locale only if the destination page actually exists since not all pages will have translation. I tried with sitemap.find_resource_by_path("/sr/#{path}")
but it always returns false even when it exists. What am I missing ?
The argument of
sitemap.find_resource_by_path
is a resource path, not destination url path. So you must do something like this :