Localizable Array: language fallbacks don't work

I have…

  • [ ] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

If one defines language fallbacks for localizable arrays they are not applied - instead the array is returned empty.

Expected behavior

Language fallbacks are applied properly for arrays as well. I guess that the issue is likely caused by squidex not being able to know whether an array is unset or just empty. So in the end the issue (and maybe the solution as well?) could be similar to [SOLVED] Assets don't use language fallbacks. Unset should be the default. Squidex could alternatively also use the minItems validation value as an indicator for the default value. In our case we set it to 1 which was then violated by the empty array response without any warning.

Minimal reproduction of the problem

  1. Define an array in a schema and make it localizable. Optionally set the minimum item count to 1 in the validation tab of the the array property.
  2. Define two languages A and B. Make A the fallback for B.
  3. Define entries for the array in the fallback language A.
  4. Don’t define entries for the array in the second language B.
  5. Make a request and set the language headers, so that they target language B. You’ll get an empty array, and not the contents defined for fallback language A.

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [x] Cloud version

Version: latest Cloud version

Browser:

  • [ ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
I can DM requests and responses as needed.

The unset button is there for all fields and should just work…

The button is there, but it doesn’t seem to do anything (apart from showing the warning dialog). When I press it with language B selected I still get an empty array afterwards.

@Sebastian I can give you access to our project or do a screen share session if that can aid you with reproduction / debugging.

I think you are right, the angular form just behaves like that for arrays …

But I don’t know how to solve it atm.

Would using the minimum item count validator as an indicator for an unset value work as a short term solution? Maybe that’s more straightforward to implement?

Yes, it would work, but it is not consistent and you can still implement it yourself in the API…

Not sure I understand: how can I implement that on my own without manually defining the fallbacks on client side and walking through the fallback languages upon receiving empty arrays? That would unnecessarily increase the number of requests against the Squidex API for certain languages. Or isn’t that what you mean?

Of course for now I can just make sure to always set the correct array contents for all defined languages and thus circumvent the fallback mechanism completely, but it can become error prone and cumbersome if many languages are involved.

You can just multiple languages with one request, e.g. the master language and the current language.

Okay, yes, that would work - but I still don’t like the double amount of data transferred as well as the need to redefine the fallback languages and everything client side. Makes my inner engineer cry - no offense. :stuck_out_tongue_winking_eye:

So I guess I’ll just tell our content editors that they need to add array items for all languages. It works fine btw if you pass a language not defined in squidex, then it will properly fall back to the master language and populate the array.

Would it be possible to make the minimum item count validator work for that case? Then I could enforce editors to set array items for all languages.

I will have a look if I can extend the angular array editor first.

1 Like

Sounds great, many thanks! :pray:

I have fixed it I think

1 Like

@Sebastian Oh, nice! What do I need to do to make it work in Squidex? Pressing the “X” for a language still results in an empty array instead of the fallback, so I guess there is something else I need to do? Or does it only apply to new content items?

I have not deployed it yet…

This topic was automatically closed after 2 days. New replies are no longer allowed.