How to translate Static Page menu items
3
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.
Native support for this is coming from the Rainlab.Translate plugin in the coming weeks.
ref. https://github.com/rainlab/translate-plugin/pull/590