getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

non translateable field should always fall back to default language #1859

Closed bnomei closed 4 years ago

bnomei commented 5 years ago

in multilang setup a field which is set to translate: false should ignore data from the languages content file but get data from default language instead. why? because this way you can make fields non translatabe later (in case you missed them when setting up the blueprint) without having to purge the field from the content file manually. i remember @texnixe posting a guide for removing fields that are not defined in the blueprint somewhere, but i do not remember if that takes multilang or the translate option into consideration.

distantnative commented 5 years ago

For this every request would need to read all blueprints as well... that would be quite a performance hit.

bnomei commented 5 years ago

oh. right. i do not want that either.

it just happend to me and i was wondering why i got no content rendered until i figured out i had all these emtpy fields in the content files. but i think we can close this issue then.

as a sidenote: why are fields written to content file if they are empty? that would prevent that issue, right? any sideeffects come to mind?

texnixe commented 5 years ago

but i do not remember if that takes multilang or the translate option into consideration.

Multilang yes, but not the translate option. The Panel would add the field again, anyway, I think, once content is updated.

But yes, it would be a good idea not to store the empty field unless there's a good reason to do so. But I have a feeling that there are enough cases where it makes sense to have the empty field.

I wouldn't want Kirby to read the blueprint files by default either.

distantnative commented 5 years ago

If you do not save empty fields, on each Panel visit the default values will be pre-filled again. But maybe you have a default but for ths page you prefer rather to have the field empty. Or e.g. un-selected.

moritzebeling commented 5 years ago

Since everyone agrees, that this can not be solved when rendering the page, as far I can see, there are only 2 remaining moments, when this can be solved:

In the end, the question is, if the panel should always check if the content is valid to the blueprint structure and, if necessary makes changes to it (e.g. by clearing a field that previously was filled, but now is untranslatable). Or if the panel allows a certain degree of inconsistency to prevent accidental data-loss while editing blueprints. I prefer the first: Upon every page/file update, the panel should check if all content and field values are valid to the blueprint and field options. Editing blueprints is mostly a in-development-action, so the dev can respond to unexpected results.

But still, if the all-at-once script above is not working or too dangerous, one would have to visit and update all the pages in the panel, where blueprints have changed. Maybe that’s a good idea for a plugin: A section for the panel dashboard, that will list all pages, where blueprint and structure are incoherent.

nilshoerrmann commented 5 years ago

Question: If we are excluding any automatic detection and handling on the frontend and focus on the backend, doesn't the panel already know everything it needs to react correctly to the situation where a non-translatable field has a (unwanted) translation stored?

The panel knows about this without any user interaction. So I'd expect two things in the panel:

  1. Either there should be an error message stating that there is a translation for an untranslatable field offering a way to dismiss this translation.
  2. Or the panel should just display the correct version from the default language and display the unsaved changes bar so that the translation is erased after hitting save.

I think the method described in the cookbook is the way to go for site-wide clean-up. But the panel should help the user to understand that a clean-up is necessary. And that can be done on page display in the panel.

Please correct we if I'm wrong :)

moritzebeling commented 5 years ago

Agree 100. The panel knows the correct structure from the blueprints, it "only" would have to "correct" existing content to match the rules. I think, this is not just about translatability, but all blueprint rules that are confronted by any existing content, right? How this could work is probably similar to the question, how the Panel should handle content when switching template (#2159).

distantnative commented 4 years ago

Bundling different issue discussions around this topic here: https://github.com/getkirby/kirby/issues/2362