October CMS resources and help articles

Simple and to the point. Optimized by the community.

How to translate Static Page menu items

by mjauvin, last modified on May 13th, 2020

The menus created using the RainLab.Pages plugin do not support translation. In order to overcome this limitation, I propose this simple solution:

When creating your menu items, use a localization string as the title (e.g. author.plugin::lang.menu.menuName)

Then when rendering the menu in your partial, just use the |trans filter to localize the menu item:

    {% for item in items if not item.viewBag.isHidden %}
        <li>{{ item.title | trans }}</li>
    {% endfor %}

Of course, you'll need to create an entry in your plugin's lang folder for those localization strings.


1 comment

Post on August 27th, 2020 9:56 PM

Native support for this is coming from the Rainlab.Translate plugin in the coming weeks.

ref. https://github.com/rainlab/translate-plugin/pull/590

We use cookies to measure the performance of this website. Do you want to accept these cookies?