whitecube / nova-flexible-content

Flexible Content & Repeater Fields for Laravel Nova
MIT License
790 stars 234 forks source link

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

Open novelnet opened 2 years ago

novelnet commented 2 years ago

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 commented 2 years ago

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

ianrobertsFF commented 2 years ago

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

novelnet commented 2 years ago

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

ianrobertsFF commented 2 years ago

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!

novelnet commented 2 years ago

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.

voidgraphics commented 2 years ago

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