How to translate extended static menu field?

Hello everyone,

I use Static Pages plugin, and I have created own plugin to add custom fields for staticMenu with viewBag as stated in plugin docs, but I’m stuck on field translation. I need separate input values for each language, so when i change Multisite language in backend, input value changes also.

Anyone got success with this in october v3 ?

Thanks :slight_smile:

My code:

    public function boot()
        Event::listen('backend.form.extendFieldsBefore', function ($widget) {
            if (
                !$widget->getController() instanceof \RainLab\Pages\Controllers\Index ||
                !$widget->model instanceof \RainLab\Pages\Classes\MenuItem
            ) {
                'viewBag[menuItemDescription]' => [
                    'label' => 'Menu item description',
                    'type' => 'text'
            // Mark the field as translatable
            $widget->model->translatable[] = 'viewBag[menuItemDescription]';

Hey @lov3

I use Tailor for this now and haven’t really looked back since.

With static pages, you’re on the right track. Maybe this? Not sure

$widget->model->translatable[] = 'menuItemDescription';

Alternatively, you could always just run the translate filter over it in the frontend to translate:

{{ item.menuDescription|_ }}

I hope this helps!