resolve/refinerycms — pull request #1161 by mirosr (2011-12-05 22:47:07+00:00)
Title: No menu item css class '.selected' in multilang frontend

It will be easier to explain the issue with an example.

Let's have a refinerycms-1.0.9 setup with two locales (:en and :de) for the frontend and :en being the default one. When a user changes the locale to :de no menu item gets '.selected' css class. The other classes ('.first' and '.last') are there but no '.selected'. When the current locale is changed again to the default one (:en) '.selected' class appears ones again.

I've tracked down the issue to the module MenuHelper and more precisely to the method selected_page?. It turns out that a trailing slash appears when the current page's url is get. When it is compared to the request.url they never match. This only occurs when the current locale is not the default one. In the example above when the current locale is :de and the current page is the home page in selected_page? the two compared strings are '/de' and '/de/'.

So what I did was to add a simple line of code to chomp the trailing slash if there is one. I'm not sure if this is the right way to resolve the issue but at least I'll pay attention to it.