nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Some Nova translations break in combination with nova-flexible-content button translation

Open novelnet opened this issue 3 years ago • 6 comments

I have set the locale to 'de'. When using nova-flexbile-content anywhere in Nova the translations break in some places only, like here:

image

When i remove the translation function __('Add layout') in Flexible.php everything works in Nova again:

public function __construct($name, $attribute = null, $resolveCallback = null)
    {
        parent::__construct($name, $attribute, $resolveCallback);

        $this->button('Add layout');
        ...

image

This issue has multiple users probably and there is also one open at Nova directly: laravel/nova-issues#4192

Thanks in advance.

novelnet avatar May 07 '22 16:05 novelnet

Can be easily solved by translating {{ __(field.button) }} in <default-button /> of SearchMenu.vue and OriginalDropMenu.vue, instead of the Field Constructor (before the translations are loaded yet). I can provide a pull request

novelnet avatar May 07 '22 19:05 novelnet

I'd make a pull request if possible, at least then the maintainers can just review and merge when they can.

ianrobertsFF avatar May 10 '22 09:05 ianrobertsFF

Any progress? Kind of critical from end user view, as this component breaks even outside in Nova translations..

novelnet avatar May 17 '22 09:05 novelnet

I can see how my colloquial phrasing of my response would suggest I was going to make the pull request, I was suggesting you do it as you said in your earlier comment, apologies!

ianrobertsFF avatar May 17 '22 09:05 ianrobertsFF

Yes, i misunderstood that. In the meantime i ended up in overriding the constructor for myself, removing the translation function and using custom labeling:

class FlexibleOverride extends Flexible {
    public function __construct($name, $attribute = null, $resolveCallback = null)
    {
        \Laravel\Nova\Fields\Field::__construct($name, $attribute, $resolveCallback);

        #https://github.com/whitecube/nova-flexible-content/issues/350
        $this->button('Add layout');

        // The original menu as default
        $this->menu('flexible-drop-menu');

        $this->hideFromIndex();
    }
}

May dig deeper in looking for a better solution to commit, when i have some time off.

novelnet avatar May 17 '22 12:05 novelnet

Thanks for investigating this. Would definitely appreciate a PR with a fix. 👍

voidgraphics avatar May 17 '22 13:05 voidgraphics