October CMS resources and help articles

Simple and to the point. Optimized by the community.

How to translate Static Page menu items

1
by mjauvin, last modified on October 7th, 2020

Update: RainLab.Pages v1.3.6 along with Rainlab.Translate v1.7.3 now support translation natively.

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:

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

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

Discussion

1 comment

0
mjauvin
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?