Open RomkaLTU opened 3 years ago
I haven't really tested it with all translatable packages and I don't know which translation package you are using. However, I have used this package along with Astronomic Laravel Translatable and I made it work.
Here's an example: NovaTinymce5Editor::make('Body', 'body:en') ->id('body_en') ->placeholder('Enter content here') ->withMeta(['mediaLibrary' => true]) ->hideFromIndex(),
MediaLibrary::make('Insert image', 'js_callback_media_library_body_en') ->jsCallback('mediaLibrarySelectFiles', ['editor' => 'body_en']) ->types(['Image']),
This is actually translations for models, there is another type of translation packages group, like https://github.com/spatie/laravel-translatable they storing translations into JSON columns. Here how it looks:
When switching between languages, we switching editors. They are all rendered simultaneously, so obviously, we can't use the same ID for all.
Sure, I am familiar with Spatie's translatable package, but like I said - I haven't tested it with. I will try to find some time to upgrade my package and make it compatible with Spatie's translatable or feel free to fork this repo and fix it. PR's welcome.
Thanks for the follow-up. Just update: this is not actually spatie/laravel-translatable problem because Nova Media Library jsCallback is targeting ID, not a class. My current workaround is very inconvenient, use TinyMCE integrated Image field and paste image source from Media library resource.
Incompatible with translatable fields (when trying to use with media library) because of ID instead of class usage. The translatable fields usually using 2 or more fields, and obviously, these fields cant have the same ID. I think this is not only this package issue but https://github.com/classic-o/nova-media-library too.