Daandelange / kirby3-TranslatedLayout

A layout field with embedded translation logic.
MIT License
17 stars 1 forks source link

Not working #2

Closed Small-Systems closed 1 year ago

Small-Systems commented 2 years ago

Something seems to be wrong with the plugin. If I set up a basic example as in the instructions, when I edit the second language the text is not saved and reverts back to the primary language value.

Daandelange commented 2 years ago

Hello, I'll check the plugin against latest Kirby versions and let you know if I find something.

Daandelange commented 2 years ago

Kirby updated : it kind of works on my side, although there seems to be some weird behaviours since v0.1.2, probably related to blueprint fieldsets parsing. Try v0.1.1 for now or try adding extends: fields/translatedlayoutwithfieldsets to your field (as in the readme).

Small-Systems commented 2 years ago

Hi, I've done a bit of extensive testing with this plugin, and I can't really work out what is going on because the block content does not actually get synced, only the visual representation in the editor. If you add blocks in the default language, then they will appear in the second language. If you remove a block from the default language, that block will not appear in the second language, but it will still be there in the layout in the .txt file for the content of that page. The content is not actually getting saved anywhere, it seems like only arrays in php are being manipulated. Also if you delete a layout from the default language, again the translation remains in the .txt file. I'd be interested in trying to get this to work as I see the need for it.

Daandelange commented 2 years ago

Hello, Indeed there seems to be something wrong... it used to work on my dev sandbox in a fresh starterkit when I published it. Probably a breaking Kirby update or some hardcoded local kirby changes I thought to be useless, still being needed.

Sorry for the late answers, I have very few time to look into this now or give directions. Try reading the comments in the source code which more or less explain my findings. The implementation is a bit hacky and reproduces quite a lot of Kirby behaviour with minor changes when the APIs are too restricted or hardcoded (https://github.com/getkirby/kirby/issues/3961). In short, the default language is always loaded as a content-structure-model, then it's merged with the translation (if the same UUID exists). The core logic happens in the Field::Fill function, and it's also where it gets more complicated, as the fill function is often called multiple times for different purposes (update/save/validate/display/etc.).

One other thing I can think of is this modification that I made to my installation while developing this, so that the panel shows modifications without reloading the page : https://github.com/getkirby/kirby/issues/3972. (ajax issue)

There's also some weird Kirby behaviour described here which might be involved : https://github.com/getkirby/kirby/issues/4110

if you delete a layout from the default language, again the translation remains in the .txt file

That feature has to be implemented, I haven't done any deletion tests.

Daandelange commented 1 year ago

Hey, I think the plugin broke in 3.7 or 3.8, it should work again now with some new features. I just tested it in a fresh starterkit. :) Please let me know if you're still having issues.

Small-Systems commented 1 year ago

Hi,

Yes it works! Was there a clear reason for the problem? I would like to use the plugin on a production site but I'm a bit wary of data loss (I know the plugin is beta, but it's so useful!).

Daandelange commented 1 year ago

Ok, glad that it works too.

I'm starting to heavily implement it on my local dev environment while I plan to use it on production in the future, but I can't guarantee anything on how well it works, it's up to you to decide. This said, I can give some insights / thoughts:

The bug... I haven't investigated deeply, but it seems related to Kirby introducing UUIDs on blocks, columns and layouts, breaking the keysToIndexes functions.