-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Implement translatable collection. #360
base: 3.x
Are you sure you want to change the base?
Conversation
…ta is not included.
PR Summary
|
I'll get into it this Friday, in the mean time, I added to the demo app and let the community helps with this |
how the {"en":{"fb8d4b1f-0f21-457f-a055-de42cbdc9856":{"itemValue":"key 1","itemKey":"1","itemIsDefault":false},"1a2c6a3e-66c9-47e8-8a9b-7789c3a9b619":{"itemValue":"key 2","itemKey":"2","itemIsDefault":false}},"es":[{"itemValue":"key es","itemKey":"1","itemIsDefault":false},{"itemValue":"key es 2","itemKey":"2","itemIsDefault":false}],"pt":[{"itemValue":"en","itemKey":"1","itemIsDefault":false}],"ko":[{"itemValue":"en","itemKey":"1","itemIsDefault":false}]} i think its related to the Translatable plugin bug. so I have to check that first. I think now I remember why I didnt enable the translatable for collection haha. either way I'll try my best to address these issues, in the mean time, you may consider using the fork. |
also check this one: bolt/src/Models/Collection.php Line 66 in 4bd122e
|
@atmonshi I have the same format: {"nl":{"5389a60a-7773-42a0-ba8a-f1a8f87705d9":{"itemValue":"Test NL","itemKey":"test","itemIsDefault":false}},"fr":[{"itemValue":"Test FR","itemKey":"test","itemIsDefault":false},{"itemValue":"Test 2 FR","itemKey":"test2","itemIsDefault":false}]} What spatie-translatable bug are you talking about? With regard to having all items in each language, I have also been pondering the options. But it is complicated, you can consider adding them automatically to each language (e.g. on the saving event), but for deletion it is maybe less save to remove them in all languages, or we need to add a tooltip on the delete button that explains this. |
this one: lara-zeus/translatable#23
this sound like a good idea, also was thinking about enable the keys for the default language only and disable it for others. will continue after the weekend, happy friday :) |
I implemented the translatable collection.
I had to remove the cast to collection of the
values
column, because laravel-translatable casts all translatable columns to array.As @atmonshi mentioned in #359, this feature is not compatible with existing data. I looked a bit at options to fix this via the
booted()
function of a model, but there is no event when data is loaded into the model. One option would be override thegetTranslation()
function on the model, but this is a complicated function, causing this implementation to break in the future.I think the cleanest way is probably to create a migration script. This should be quite easy and can be done on query level, see spatie/laravel-translatable#111
What do you think?