Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multilingual #7

Closed
thanoseleftherakos opened this issue Mar 6, 2019 · 10 comments
Closed

Multilingual #7

thanoseleftherakos opened this issue Mar 6, 2019 · 10 comments
Labels
bug Something isn't working

Comments

@thanoseleftherakos
Copy link

First of all congratulation for the plugin, amazing work!
Do you have any plans supporting multilingual packages like spatie Nova Translatable?
I've tried it but it's not compatible

Thank you

@voidgraphics
Copy link
Member

Hello @thanoseleftherakos, thank you for the kind words.

We do plan on having the functionality to include any and every field out there if we can, we're hoping to find a way to make them all work at once.

We would absolutely love a PR that fixes it as well, if anyone feels up to it.

@voidgraphics voidgraphics added the bug Something isn't working label Mar 6, 2019
@toonvandenbos
Copy link
Member

This issue is valid for every field that stores its values as JSON strings. In fact, it is for example not possible to have a Flexible inside another Flexible at the moment for the exact same reason. Resolving this issue will benefit a lot of other issues with complex fields as well and therefore we'll have to take a look at it soon.

Thanks for bringing this to our attention.

@YannikFirre
Copy link

Good catch but the response of spatie on this subject is categorical : spatie/laravel-translatable#154

@voidgraphics
Copy link
Member

I think the functionality of Spatie's package is good as is - the plan is to make our package work with theirs, not the opposite 🙂

@toonvandenbos
Copy link
Member

Spatie's response would apply if you wanted to use a Flexible field as a "translatable field". In most cases, the translatable fields should only apply to "final" fields, meaning you'll probably have to use the translatable fields inside the Flexible field.

@toonvandenbos
Copy link
Member

toonvandenbos commented Mar 7, 2019

Alright.

Nested complex fields (= fields that return serializable data) should now be supported as long as they do not json_encode their value when filling the model (or layout attributes in our case).

After a few quick tests, nested Flexible fields and Translatable fields (tested with mrmonat/nova-translatable) are working fine.

A quick note on Translatable fields using spatie/laravel-translatable under the hood: you should not use the HasTranslations trait on your Flexible layouts, which is actually good news. The trait will transform the attribute into a JSON string and as I mentioned earlier, that's something we don't want.

I will publish a release containing these changes (and some other enhancements) right away.

@thanoseleftherakos
Copy link
Author

Hello,
@Nyratas is this fix on version 0.1.2?
I've tried it but Im getting "Trying to get property 'layout' of non-object" when I use mrmonat/nova-translatable

@toonvandenbos
Copy link
Member

Hi @thanoseleftherakos,

Yep, this fix was one of the reasons of 0.1.2.
Could you show your setup?

@JurjenRoels
Copy link

I am trying to get kongulov/nova-tab-translatable working with flexible content.

What I would like to have is to have a tab for each language. The (nested) flexible_content would be part of that tab.

But if I read the above information it is not possible to create that?

I tried the solution in #44 to add a separate appended field. But still get the $stdClass::Layout error.

@joeholston
Copy link

Could someone please explain/show an example of making a nested field translatable on a model? My model implements HasTranslations/translatable for other fields, but I am not sure how to denote that 'Heading' inside of a Flexible layout is translatable.

Flexible::make('About Sections')->addLayout('Text', 'text', [ Translatable::make('Heading')->singleLine() ]),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants